How to use the sift.useOperator function in sift

To help you get started, we’ve selected a few sift 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 joakimbeng / relae / src / store.js View on Github external
import update from 'react/lib/update';
import sift from 'sift';
import eventEmitter from 'event-emitter';

let idProperty = 'id';

sift.useOperator('id', (a, b) => a === b[idProperty]);
sift.useOperator('limit', () => true);
sift.useOperator('skip', () => true);

const ee = eventEmitter();

let storage = {};

function setState(state) {
  storage = update(storage, {$merge: state});
  Object.keys(state).forEach(key => ee.emit('change', key));
}

function getRequestData(request, params) {
  const collection = storage[request.collection] || [];
  let data = sift(params, collection);
  if (request.params.$id) {
github joakimbeng / relae / src / store.js View on Github external
import update from 'react/lib/update';
import sift from 'sift';
import eventEmitter from 'event-emitter';

let idProperty = 'id';

sift.useOperator('id', (a, b) => a === b[idProperty]);
sift.useOperator('limit', () => true);
sift.useOperator('skip', () => true);

const ee = eventEmitter();

let storage = {};

function setState(state) {
  storage = update(storage, {$merge: state});
  Object.keys(state).forEach(key => ee.emit('change', key));
}

function getRequestData(request, params) {
  const collection = storage[request.collection] || [];
  let data = sift(params, collection);
  if (request.params.$id) {
    return data && data[0];
github joakimbeng / relae / src / store.js View on Github external
import update from 'react/lib/update';
import sift from 'sift';
import eventEmitter from 'event-emitter';

let idProperty = 'id';

sift.useOperator('id', (a, b) => a === b[idProperty]);
sift.useOperator('limit', () => true);
sift.useOperator('skip', () => true);

const ee = eventEmitter();

let storage = {};

function setState(state) {
  storage = update(storage, {$merge: state});
  Object.keys(state).forEach(key => ee.emit('change', key));
}

function getRequestData(request, params) {
  const collection = storage[request.collection] || [];
  let data = sift(params, collection);
  if (request.params.$id) {
    return data && data[0];
  }

sift

MongoDB query filtering in JavaScript

MIT
Latest version published 8 months ago

Package Health Score

77 / 100
Full package analysis