How to use the dot-object.pick function in dot-object

To help you get started, we’ve selected a few dot-object examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cult-of-coders / grapher / lib / query / hypernova / assembler.js View on Github external
parent.results.forEach(parentResult => {
            // support dotted fields
            const [root, ...nested] = fieldStorage.split('.');
            const value = dot.pick(root, parentResult);
            if (!value) {
                return;
            }


            const data = [];
            value.forEach(v => {
                const _id = nested.length > 0 ? dot.pick(nested.join('.'), v) : v;
                data.push(_.first(resultsByKeyId[_id]));
            });

            parentResult[childCollectionNode.linkName] = filterAssembledData(
                data,
                { limit, skip }
            );
        });
github zackiles / elasticsearch-odm / lib / query.js View on Github external
function addExistenceFilters(req, missingFilters, existsFilters){
  // see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-missing-filter.html
  // and https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filters.html

  // is this a filtered query, or a regulat?
  var boolFilter = dot.pick('body.query.filtered', req);

  var getPreviousFilters = function(){
    var andFilters;
    if(boolFilter){
      andFilters = dot.pick('body.query.filtered.query.constant_score.filter.and', req);
    }else{
      andFilters = dot.pick('body.query.constant_score.filter.and', req);
    }
    return andFilters || [];
  };

  var query = {
    constant_score: {
      filter: {
        and: getPreviousFilters()
      }
github zackiles / elasticsearch-odm / lib / query.js View on Github external
return f;
  };

  filter.bool.must = _.map(mustFilters, makeTermFilter);
  filter.bool.must_not = _.map(notFilters, makeTermFilter);

  // Remove any empty filters, Elasticsearch will throw an error.
  _.each(filter.bool, function(v, k) {
    if(!v || !v.length) delete filter.bool[k];
  });

  // No filters found? return now.
  if(_.isEmpty(filter.bool)) return void 0;

  // Is this a new filtered query, or an existing to merge with?
  var boolFilter = dot.pick('body.query.filtered.filter.bool', req);

  var mergeFilter = function(filterName, data){
    if( _.isArray(boolFilter[filterName]) ){
      req.body.query.filtered.filter.bool[filterName] = req.body.query.filtered.filter.bool[filterName].concat(data);
    }else if( _.isPlainObject(boolFilter[filterName]) ){
      req.body.query.filtered.filter.bool[filterName] = [boolFilter[filterName]];
      req.body.query.filtered.filter.bool[filterName] = req.body.query.filtered.filter.bool[filterName].concat(data);
    }else{
      req.body.query.filtered.filter.bool[filterName] = data;
    }
  };

  if(boolFilter){
    if(filter.bool.must) mergeFilter('must', filter.bool.must);
    if(filter.bool.must_not) mergeFilter('must_not', filter.bool.must_not);
  }else{
github psvet / obey / src / lib / validators.js View on Github external
requiredIfNot: function(def, value, key, errors, data) {
    const type = 'requiredIfNot'
    const sub = def.requiredIfNot
    if (typeof sub === 'object') {
      const field = Object.keys(sub)[0]
      const fieldArr = Array.isArray(sub[field]) ? sub[field] : [ sub[field] ]
      fieldArr.some(val => {
        /* istanbul ignore else */
        if (dot.pick(field, data) !== val && value === undefined) {
          errors.push({ type, sub, key, value, message: `Value required because '${field}' value is not one specified` })
          return true
        }
      })
    } else if (dot.pick(sub, data) === undefined && value === undefined) {
      errors.push({ type, sub, key, value, message: `Value required because '${sub}' is undefined`})
    }
  },
  /**
github CBIConsulting / ProperTable / src / jsx / lib / rowcache.js View on Github external
read(key) {
		let k = parseKey(key);
		return dot.pick(k, cache);
	}
github MitocGroup / recink / src / container.js View on Github external
has(path) {
    return typeof dot.pick(path, this._config) !== 'undefined';
  }
github cult-of-coders / grapher / lib / links / linkTypes / linkMany.js View on Github external
    _id => !_.contains(_ids, nested.length > 0 ? dot.pick(nested.join('.'), _id) : _id)
        );
github zackiles / elasticsearch-odm / lib / query.js View on Github external
var getPreviousFilters = function(){
    var andFilters;
    if(boolFilter){
      andFilters = dot.pick('body.query.filtered.query.constant_score.filter.and', req);
    }else{
      andFilters = dot.pick('body.query.constant_score.filter.and', req);
    }
    return andFilters || [];
  };
github nicolaslopezj / simple-react-form / src / Field.js View on Github external
getValue () {
    return this.context.doc ? DotObject.pick(this.getFieldName(), this.context.doc) : undefined
  }
github streamplace / streamplace / apps / gort / src / components / SKField.jsx View on Github external
render () {
    const value = dot.pick(this.props.field, this.props.data) || "";
    return (
      <div>
        <label>{this.props.label}</label>
        <input value="{value}" placeholder="{this.props.placeholder}" type="text" id="{this.id}">
      </div>
    );
  }
}

dot-object

dot-object makes it possible to transform and read (JSON) objects using dot notation.

MIT
Latest version published 8 months ago

Package Health Score

63 / 100
Full package analysis