How to use the @feathersjs/commons._.extend function in @feathersjs/commons

To help you get started, we’ve selected a few @feathersjs/commons 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 feathersjs-ecosystem / feathers-knex / lib / index.js View on Github external
_patch (id, raw, params = {}) {
    // Do not allow to patch the id
    const data = _.omit(raw, this.id);
    // By default we will just query for the one id. For multi patch
    // we create a list of the ids of all items that will be changed
    // to re-query them after the update
    return this._findOrGet(id, Object.assign({}, params, {
      query: _.extend({}, params.query, { $select: [`${this.table}.${this.id}`] })
    })).then(results => {
      const idList = results.map(current => current[this.id]);
      const query = {
        [`${this.table}.${this.id}`]: { $in: idList }
      };
      const q = this.knexify(this.db(params), query);
      const findParams = Object.assign({}, params, {
        query: Object.assign({}, params.query, query)
      });

      return q.update(data).then(() => {
        return this._findOrGet(null, findParams).then(items => {
          if (id !== null) {
            if (items.length === 1) {
              return items[0];
            } else {
github feathersjs-ecosystem / feathers-nedb / lib / index.js View on Github external
async _findOrGet (id, params = {}) {
    if (id === null) {
      return this._find(_.extend({}, params, {
        paginate: false
      }));
    }

    return this._get(id, params);
  }
github feathersjs-ecosystem / feathers-memory / lib / index.js View on Github external
async _create (data, params = {}) {
    if (Array.isArray(data)) {
      return Promise.all(data.map(current => this._create(current, params)));
    }

    const id = data[this.id] || this._uId++;
    const current = _.extend({}, data, { [this.id]: id });
    const result = (this.store[id] = current);

    return _select(result, params, this.id);
  }
github feathersjs-ecosystem / feathers-memory / lib / index.js View on Github external
constructor (options = {}) {
    super(_.extend({
      id: 'id',
      matcher: sift,
      sorter
    }, options));
    this._uId = options.startId || 0;
    this.store = options.store || {};
  }