How to use the lokijs.LokiOps function in lokijs

To help you get started, we’ve selected a few lokijs 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 RocketChat / Rocket.Chat / packages / rocketchat-lib / server / models / _BaseCache.js View on Github external
/* eslint new-cap: 0 */

import loki from 'lokijs';
import {EventEmitter} from 'events';
import objectPath from 'object-path';

const logger = new Logger('BaseCache');

const lokiEq = loki.LokiOps.$eq;
const lokiNe = loki.LokiOps.$ne;

loki.LokiOps.$eq = function(a, b) {
	if (Array.isArray(a)) {
		return a.indexOf(b) !== -1;
	}
	return lokiEq(a, b);
};

loki.LokiOps.$ne = function(a, b) {
	if (Array.isArray(a)) {
		return a.indexOf(b) === -1;
	}
	return lokiNe(a, b);
};
github RocketChat / Rocket.Chat / packages / rocketchat-lib / server / models / _BaseCache.js View on Github external
/* eslint new-cap: 0 */

import loki from 'lokijs';
import {EventEmitter} from 'events';
import objectPath from 'object-path';

const logger = new Logger('BaseCache');

const lokiEq = loki.LokiOps.$eq;
const lokiNe = loki.LokiOps.$ne;

loki.LokiOps.$eq = function(a, b) {
	if (Array.isArray(a)) {
		return a.indexOf(b) !== -1;
	}
	return lokiEq(a, b);
};

loki.LokiOps.$ne = function(a, b) {
	if (Array.isArray(a)) {
		return a.indexOf(b) === -1;
	}
	return lokiNe(a, b);
};

const lokiIn = loki.LokiOps.$in;
loki.LokiOps.$in = function(a, b) {
	if (Array.isArray(a)) {
github RocketChat / Rocket.Chat / packages / rocketchat-lib / server / models / _BaseCache.js View on Github external
return !loki.LokiOps.$in(a, b);
};

loki.LokiOps.$all = function(a, b) {
	return b.every(subB => a.includes(subB));
};

loki.LokiOps.$exists = function(a, b) {
	if (b) {
		return loki.LokiOps.$ne(a, undefined);
	}

	return loki.LokiOps.$eq(a, undefined);
};

loki.LokiOps.$elemMatch = function(a, b) {
	return _.findWhere(a, b);
};

const ignore = [
	'emit',
	'load',
	'on',
	'addToAllIndexes'
];

function traceMethodCalls(target) {
	target._stats = {};

	for (const property in target) {
		if (typeof target[property] === 'function' && ignore.indexOf(property) === -1) {
			target._stats[property] = {
github RocketChat / Rocket.Chat / packages / rocketchat-lib / server / models / _BaseCache.js View on Github external
loki.LokiOps.$exists = function(a, b) {
	if (b) {
		return loki.LokiOps.$ne(a, undefined);
	}

	return loki.LokiOps.$eq(a, undefined);
};
github RocketChat / Rocket.Chat / packages / rocketchat-lib / server / models / _BaseCache.js View on Github external
import {EventEmitter} from 'events';
import objectPath from 'object-path';

const logger = new Logger('BaseCache');

const lokiEq = loki.LokiOps.$eq;
const lokiNe = loki.LokiOps.$ne;

loki.LokiOps.$eq = function(a, b) {
	if (Array.isArray(a)) {
		return a.indexOf(b) !== -1;
	}
	return lokiEq(a, b);
};

loki.LokiOps.$ne = function(a, b) {
	if (Array.isArray(a)) {
		return a.indexOf(b) === -1;
	}
	return lokiNe(a, b);
};

const lokiIn = loki.LokiOps.$in;
loki.LokiOps.$in = function(a, b) {
	if (Array.isArray(a)) {
		return a.some(subA => lokiIn(subA, b));
	}
	return lokiIn(a, b);
};

loki.LokiOps.$nin = function(a, b) {
	return !loki.LokiOps.$in(a, b);
github RocketChat / Rocket.Chat / packages / rocketchat-lib / server / models / _BaseCache.js View on Github external
loki.LokiOps.$in = function(a, b) {
	if (Array.isArray(a)) {
		return a.some(subA => lokiIn(subA, b));
	}
	return lokiIn(a, b);
};

loki.LokiOps.$nin = function(a, b) {
	return !loki.LokiOps.$in(a, b);
};

loki.LokiOps.$all = function(a, b) {
	return b.every(subB => a.includes(subB));
};

loki.LokiOps.$exists = function(a, b) {
	if (b) {
		return loki.LokiOps.$ne(a, undefined);
	}

	return loki.LokiOps.$eq(a, undefined);
};

loki.LokiOps.$elemMatch = function(a, b) {
	return _.findWhere(a, b);
};

const ignore = [
	'emit',
	'load',
	'on',
	'addToAllIndexes'
github RocketChat / Rocket.Chat / packages / rocketchat-lib / server / models / _BaseCache.js View on Github external
return lokiNe(a, b);
};

const lokiIn = loki.LokiOps.$in;
loki.LokiOps.$in = function(a, b) {
	if (Array.isArray(a)) {
		return a.some(subA => lokiIn(subA, b));
	}
	return lokiIn(a, b);
};

loki.LokiOps.$nin = function(a, b) {
	return !loki.LokiOps.$in(a, b);
};

loki.LokiOps.$all = function(a, b) {
	return b.every(subB => a.includes(subB));
};

loki.LokiOps.$exists = function(a, b) {
	if (b) {
		return loki.LokiOps.$ne(a, undefined);
	}

	return loki.LokiOps.$eq(a, undefined);
};

loki.LokiOps.$elemMatch = function(a, b) {
	return _.findWhere(a, b);
};

const ignore = [
github RocketChat / Rocket.Chat / packages / rocketchat-lib / server / models / _BaseCache.js View on Github external
loki.LokiOps.$eq = function(a, b) {
	if (Array.isArray(a)) {
		return a.indexOf(b) !== -1;
	}
	return lokiEq(a, b);
};

loki.LokiOps.$ne = function(a, b) {
	if (Array.isArray(a)) {
		return a.indexOf(b) === -1;
	}
	return lokiNe(a, b);
};

const lokiIn = loki.LokiOps.$in;
loki.LokiOps.$in = function(a, b) {
	if (Array.isArray(a)) {
		return a.some(subA => lokiIn(subA, b));
	}
	return lokiIn(a, b);
};

loki.LokiOps.$nin = function(a, b) {
	return !loki.LokiOps.$in(a, b);
};

loki.LokiOps.$all = function(a, b) {
	return b.every(subB => a.includes(subB));
};

loki.LokiOps.$exists = function(a, b) {
	if (b) {
github RocketChat / Rocket.Chat / packages / rocketchat-lib / server / models / _BaseCache.js View on Github external
loki.LokiOps.$ne = function(a, b) {
	if (Array.isArray(a)) {
		return a.indexOf(b) === -1;
	}
	return lokiNe(a, b);
};

const lokiIn = loki.LokiOps.$in;
loki.LokiOps.$in = function(a, b) {
	if (Array.isArray(a)) {
		return a.some(subA => lokiIn(subA, b));
	}
	return lokiIn(a, b);
};

loki.LokiOps.$nin = function(a, b) {
	return !loki.LokiOps.$in(a, b);
};

loki.LokiOps.$all = function(a, b) {
	return b.every(subB => a.includes(subB));
};

loki.LokiOps.$exists = function(a, b) {
	if (b) {
		return loki.LokiOps.$ne(a, undefined);
	}

	return loki.LokiOps.$eq(a, undefined);
};

loki.LokiOps.$elemMatch = function(a, b) {
github gridsome / gridsome / gridsome / lib / store / Store.js View on Github external
const Loki = require('lokijs')
const autoBind = require('auto-bind')
const NodeIndex = require('./NodeIndex')
const EventEmitter = require('eventemitter3')
const { deprecate } = require('../utils/deprecate')
const { isArray, isPlainObject } = require('lodash')
const Collection = require('./Collection')
const { safeKey } = require('../utils')
const lokiOps = require('./lokiOps')

const { SyncWaterfallHook } = require('tapable')
const SyncBailWaterfallHook = require('../app/SyncBailWaterfallHook')

Object.assign(Loki.LokiOps, lokiOps)

class Store {
  constructor (app) {
    this.app = app
    this.collections = {}
    this.nodeIndex = new NodeIndex(app)
    this._events = new EventEmitter()

    this.lastUpdate = null
    this.setUpdateTime()

    autoBind(this)

    this.metadata = new Loki.Collection('core/metadata', {
      unique: ['key'],
      autoupdate: true