How to use @lykmapipo/common - 4 common examples

To help you get started, we’ve selected a few @lykmapipo/common 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 lykmapipo / mongoose-rest-actions / lib / put.js View on Github external
const updatesFor = (id, updates) => {
  // normalize id
  const options = _.isPlainObject(id) ? id : { _id: id };

  // ignore self instance updates
  if (isInstance(updates) && updates._id === options._id) {
    return updates;
  }

  // compute updates
  const changes = mergeObjects(copyInstance(updates), options);
  return changes;
};
github lykmapipo / mongoose-rest-actions / lib / patch.js View on Github external
function doPatch(instance, next) {
          //update & persist instance
          if (body && !_.isEmpty(body)) {
            // copy existing paths & merge with updates
            const exists = _.pick(copyInstance(instance), ..._.keys(body));
            const changes = mergeObjects(exists, body);
            instance.set(changes);
          }
          instance.updatedAt = new Date();
          instance.save(function afterSave(error, saved) {
            next(error, saved);
          });
        },
github lykmapipo / mongoose-rest-actions / lib / patch.js View on Github external
const updatesFor = (id, updates) => {
  // normalize id
  const options = _.isPlainObject(id) ? id : { _id: id };

  // ignore self instance updates
  if (isInstance(updates) && updates._id === options._id) {
    return updates;
  }

  // compute updates
  const changes = mergeObjects(copyInstance(updates), options);
  return changes;
};
github lykmapipo / mongoose-rest-actions / lib / put.js View on Github external
function doPut(instance, next) {
          //update & persist instance
          if (body && !_.isEmpty(body)) {
            // copy existing paths & merge with updates
            const exists = _.pick(copyInstance(instance), ..._.keys(body));
            const changes = mergeObjects(exists, body);
            instance.set(changes);
          }
          instance.updatedAt = new Date();
          instance.save(function afterSave(error, saved) {
            next(error, saved);
          });
        },

@lykmapipo/common

Helper utilities for day to day development

MIT
Latest version published 2 years ago

Package Health Score

51 / 100
Full package analysis

Popular @lykmapipo/common functions