How to use the lokijs.Collection 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 gridsome / gridsome / gridsome / lib / store / Collection.js View on Github external
constructor (typeName, options, store) {
    this.typeName = typeName
    this.options = options || {}

    this._store = store
    this._transformers = store._transformers
    this._events = new EventEmitter()
    this._collection = new Collection(typeName, {
      indices: ['id', 'path', 'internal.typeName'],
      unique: ['id', 'path'],
      disableMeta: true
    })

    this._refs = mapValues(options.refs, (ref, key) => ({
      typeName: ref.typeName || options.typeName,
      fieldName: key
    }))

    this._mimeTypes = {}
    this._fields = options.fields || {}
    this._dateField = options.dateField || 'date'
    this._defaultSortBy = this._dateField
    this._defaultSortOrder = 'DESC'
github gridsome / gridsome / gridsome / lib / pages / pages.js View on Github external
createPage: new SyncWaterfallHook(['options']),
      pageContext: new SyncWaterfallHook(['context', 'data'])
    }

    this._componentCache = new LRU({ max: 100 })
    this._queryCache = new LRU({ max: 100 })
    this._watched = new Map()
    this._watcher = null

    this._routes = new Collection('routes', {
      indices: ['id'],
      unique: ['id', 'path', 'internal.priority'],
      disableMeta: true
    })

    this._pages = new Collection('pages', {
      indices: ['id'],
      unique: ['id', 'path'],
      disableMeta: true
    })

    if (isDev) {
      this._watcher = new FSWatcher({
        disableGlobbing: true
      })

      initWatcher(app, this)
    }
  }
github gridsome / gridsome / gridsome / lib / store / Store.js View on Github external
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
    })

    this.hooks = {
      addCollection: new SyncWaterfallHook(['options']),
      addNode: new SyncBailWaterfallHook(['options', 'collection'])
    }

    this.hooks.addNode.tap('TransformNodeContent', require('./transformNodeContent'))
    this.hooks.addNode.tap('ProcessNodeFields', require('./processNodeFields'))
  }
github gridsome / gridsome / gridsome / lib / store / NodeIndex.js View on Github external
constructor (app) {
    this.app = app

    this.hooks = {
      addEntry: new SyncWaterfallHook(['entry', 'node', 'collection'])
    }

    this.hooks.addEntry.tap('BelongsToProcessor', require('./processNodeReferences'))

    this.index = new Collection('NodeIndex', {
      indices: ['typeName', 'id'],
      unique: ['uid'],
      disableMeta: true
    })
  }
github gridsome / gridsome / gridsome / lib / pages / pages.js View on Github external
constructor (app) {
    this.app = app

    this.hooks = {
      parseComponent: new HookMap(() => new SyncBailHook(['source', 'resource'])),
      createRoute: new SyncWaterfallHook(['options']),
      createPage: new SyncWaterfallHook(['options']),
      pageContext: new SyncWaterfallHook(['context', 'data'])
    }

    this._componentCache = new LRU({ max: 100 })
    this._queryCache = new LRU({ max: 100 })
    this._watched = new Map()
    this._watcher = null

    this._routes = new Collection('routes', {
      indices: ['id'],
      unique: ['id', 'path', 'internal.priority'],
      disableMeta: true
    })

    this._pages = new Collection('pages', {
      indices: ['id'],
      unique: ['id', 'path'],
      disableMeta: true
    })

    if (isDev) {
      this._watcher = new FSWatcher({
        disableGlobbing: true
      })