How to use the js-data.utils.get 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 js-data / js-data-firebase / src / index.js View on Github external
return utils.Promise.all(records.map((record) => {
          return this._destroy(mapper, utils.get(record, idAttribute), opts)
        }))
      })
github js-data / js-data-firebase / src / index.js View on Github external
      result[0] = result[0].reduce((sum, record) => sum + (utils.get(record, field) || 0), 0)
      return result
github js-data / js-data-firebase / src / index.js View on Github external
records.forEach((record) => {
      const id = utils.get(record, idAttribute)
      let _props = utils.plainCopy(record)
      let itemRef

      if (utils.isSorN(id)) {
        itemRef = collectionRef.child(id)
      } else {
        itemRef = collectionRef.push()
        utils.set(_props, idAttribute, itemRef.key)
      }
      refValueCollection.push({ ref: itemRef, props: _props })
    })
github GoogleCloudPlatform / js-data-cloud-datastore / src / index.js View on Github external
    const tasks = records.map((record) => this._find(mapper, utils.get(record, idAttribute), opts));
    return utils.Promise.all(tasks).then((results) => {
github js-data / js-data-firebase / src / index.js View on Github external
_upsert (mapper, props, opts) {
    const _props = utils.plainCopy(props)
    opts || (opts = {})

    const id = utils.get(_props, mapper.idAttribute)
    const collectionRef = this.getRef(mapper, opts)

    let itemRef

    if (utils.isSorN(id)) {
      itemRef = collectionRef.child(id)
    } else {
      itemRef = collectionRef.push()
      utils.set(_props, mapper.idAttribute, itemRef.key)
    }

    return itemRef.set(_props)
      .then(() => this._once(itemRef))
      .then((record) => {
        if (!record) {
          throw new Error('Not Found')
github js-data / js-data-http / src / index.js View on Github external
let parentId = opts.params[parentKey]

      if (parentId === false || !parentKey || !parentDef) {
        if (parentId === false) {
          delete opts.params[parentKey]
        }
        return false
      } else {
        delete opts.params[parentKey]

        if (utils.isObject(id)) {
          item = id
        }

        if (item) {
          parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)
        }

        if (parentId) {
          delete opts.endpoint
          const _opts = {}
          utils.forOwn(opts, (value, key) => {
            _opts[key] = value
          })
          utils._(_opts, parentDef)
          endpoint = makePath(this.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)
          return false
        }
      }
    })
github GoogleCloudPlatform / js-data-cloud-datastore / src / index.js View on Github external
records.forEach((record, i) => {
        if (!record) {
          return;
        }
        const id = utils.get(record, idAttribute);
        if (!utils.isUndefined(id)) {
          utils.deepMixIn(record, props[i]);
          entities.push({
            method: 'update',
            key: this.datastore.key([this.getKind(mapper, opts), id]),
            data: record
          });
          _records.push(record);
        }
      });
      if (!_records.length) {