How to use the js-data.utils.isObject function in js-data

To help you get started, we’ve selected a few js-data 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 GoogleCloudPlatform / js-data-cloud-datastore / src / index.js View on Github external
utils.forOwn(query, (config, keyword) => {
      if (reserved.indexOf(keyword) === -1) {
        if (utils.isObject(config)) {
          query.where[keyword] = config;
        } else {
          query.where[keyword] = {
            '==': config
          };
        }
        delete query[keyword];
      }
    });
github GoogleCloudPlatform / js-data-cloud-datastore / src / index.js View on Github external
loadHasOne (mapper, def, records, __opts) {
    if (utils.isObject(records) && !utils.isArray(records)) {
      return Adapter.prototype.loadHasOne.call(this, mapper, def, records, __opts);
    }
    throw new Error('findAll with hasOne not supported!');
  },
github js-data / js-data-sql / src / index.js View on Github external
utils.forOwn(query, (config, keyword) => {
      if (reserved.indexOf(keyword) === -1) {
        if (utils.isObject(config)) {
          query.where[keyword] = config
        } else {
          query.where[keyword] = {
            '==': config
          }
        }
        delete query[keyword]
      }
    })
github js-data / js-data-http / src / index.js View on Github external
val.forEach(function (v) {
      if (toString.call(v) === '[object Date]') {
        v = v.toISOString()
      } else if (utils.isObject(v)) {
        v = utils.toJson(v)
      }
      parts.push(`${encode(key)}=${encode(v)}`)
    })
  })
github Wikodit / js-data-jsonapi-light / src / main.ts View on Github external
for (let id in itemsIndexed[type]) {
        let item:any = itemsIndexed[type][id];
        item.attributes[resource.idAttribute] = id;

        if (!item.relationships || !Object.keys(item.relationships)) continue;

        for (let relationField in (item.relationships || {})) {
          let relation:any = resource.relationByField[relationField]
          if (!relation || !item.relationships[relationField] || !item.relationships[relationField].data) {
            continue;
          }

          if (relation.type === 'belongsTo' || relation.type === 'hasOne') {
            let link:any = item.relationships[relationField].data
            if (!utils.isObject(link)) {
              this.warn('Wrong relation somewhere, object expected', relation);
              continue;
            }

            if (itemsIndexed[link.type] && itemsIndexed[link.type][link.id]) {
              let itemLinked:any = itemsIndexed[link.type][link.id];
              item.attributes[relation.localField] = itemLinked.attributes;
            }
          } else if (relation.type === 'hasMany') {
            let links:any = item.relationships[relationField].data
            if (!utils.isArray(links)) {
              this.warn('Wrong relation somewhere, array expected');
              continue;
            }

            item.attributes[relation.localField] = [];
github js-data / js-data-rethinkdb / src / index.js View on Github external
utils.forOwn(where, (clause, field) => {
      if (!utils.isObject(clause)) {
        clause = {
          '==': clause
        }
      }
      utils.forOwn(clause, (expr, op) => {
        fields.push(field)
        ops.push(op)
        predicates.push(expr)
      })
    })
    return {
github js-data / js-data-mongodb / src / index.js View on Github external
utils.forOwn(query.where, function (criteria, field) {
        if (!utils.isObject(criteria)) {
          query.where[field] = {
            '==': criteria
          }
        }
        utils.forOwn(criteria, function (v, op) {
          if (op === '==' || op === '===' || op === 'contains') {
            mongoQuery[field] = v
          } else if (op === '!=' || op === '!==' || op === 'notContains') {
            mongoQuery[field] = mongoQuery[field] || {}
            mongoQuery[field].$ne = v
          } else if (op === '>') {
            mongoQuery[field] = mongoQuery[field] || {}
            mongoQuery[field].$gt = v
          } else if (op === '>=') {
            mongoQuery[field] = mongoQuery[field] || {}
            mongoQuery[field].$gte = v
github Wikodit / js-data-jsonapi-light / src / deserializer.ts View on Github external
for (let id in itemsIndexed[type]) {
      let item:any = itemsIndexed[type][id];
      item.attributes[resource.idAttribute] = id;

      if (!item.relationships || !Object.keys(item.relationships)) continue;

      for (let relationField in (item.relationships || {})) {
        let relation:any = resource.relationByField[relationField]
        if (!relation || !item.relationships[relationField] || !item.relationships[relationField].data) {
          continue;
        }

        if (relation.type === 'belongsTo' || relation.type === 'hasOne') {
          let link:any = item.relationships[relationField].data
          if (!utils.isObject(link)) {
            this.warn(WARNING.WRONG_RELATION_OBJECT_EXPECTED, relation);
            continue;
          }

          if (itemsIndexed[link.type] && itemsIndexed[link.type][link.id]) {
            let itemLinked:any = itemsIndexed[link.type][link.id];
            item.attributes[relation.localField] = itemLinked.attributes;
          }
        } else if (relation.type === 'hasMany') {
          let links:any = item.relationships[relationField].data
          if (!utils.isArray(links)) {
            this.warn(WARNING.WRONG_RELATION_ARRAY_EXPECTED);
            continue;
          }

          item.attributes[relation.localField] = [];
github js-data / js-data-mongodb / src / index.js View on Github external
utils.forOwn(query, function (config, keyword) {
      if (reserved.indexOf(keyword) === -1) {
        if (utils.isObject(config)) {
          query.where[keyword] = config
        } else {
          query.where[keyword] = {
            '==': config
          }
        }
        delete query[keyword]
      }
    })
github js-data / js-data-rethinkdb / src / index.js View on Github external
utils.forOwn(query, (config, keyword) => {
      if (reserved.indexOf(keyword) === -1) {
        if (utils.isObject(config)) {
          query.where[keyword] = config
        } else {
          query.where[keyword] = {
            '==': config
          }
        }
        delete query[keyword]
      }
    })