How to use the sift.compare 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 williamkapke / mongo-mock / sift.js View on Github external
var sift = require('sift');

//use a custom compare function so we can search on ObjectIDs
var compare = sift.compare;
sift.compare = function(a, b) {
  if(a && b && a._bsontype && b._bsontype) {
    return a.equals(b)? 0 : (compare(time(a), time(b)) || compare(a.toHexString(), b.toHexString()));
  }
  return compare(a,b);
};
function time(id) {
  return id.getTimestamp().getTime()
}

module.exports = sift;
github williamkapke / mongo-mock / sift.js View on Github external
var sift = require('sift');

//use a custom compare function so we can search on ObjectIDs
var compare = sift.compare;
sift.compare = function(a, b) {
  if(a && b && a._bsontype && b._bsontype) {
    return a.equals(b)? 0 : (compare(time(a), time(b)) || compare(a.toHexString(), b.toHexString()));
  }
  return compare(a,b);
};
function time(id) {
  return id.getTimestamp().getTime()
}

module.exports = sift;

sift

MongoDB query filtering in JavaScript

MIT
Latest version published 8 months ago

Package Health Score

77 / 100
Full package analysis