How to use @jsreport/mingo - 2 common examples

To help you get started, we’ve selected a few @jsreport/mingo 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 jsreport / jsreport-core / lib / store / memoryStoreProvider.js View on Github external
find (entitySet, query, fields, opts = {}) {
    const documents = getDocuments(this.documents[entitySet], opts).map((d) => {
      if (opts.transaction && d.$transaction.active[opts.transaction.id] && d.$transaction.active[opts.transaction.id].updatedDoc) {
        return d.$transaction.active[opts.transaction.id].updatedDoc
      }

      return d
    })

    const cursor = mingo.find(documents, query, fields)
    cursor.toArray = () => cursor.all().map((e) => omit(extend(true, {}, e), '$transaction'))
    return cursor
  },
github jsreport / jsreport-core / lib / store / memoryStoreProvider.js View on Github external
update (entitySet, q, u, opts = {}) {
    const documents = getDocuments(this.documents[entitySet], opts)
    const toUpdate = mingo.find(documents, q).all()

    if (toUpdate.length === 0 && opts.upsert) {
      this.insert(entitySet, u.$set, opts)
    } else {
      toUpdate.forEach((d) => {
        if (opts.transaction) {
          d.$transaction = d.$transaction || { active: {} }
          d.$transaction.active[opts.transaction.id] = d.$transaction.active[opts.transaction.id] || {}
          d.$transaction.active[opts.transaction.id].updatedDoc = omit(extend(true, {}, d, u.$set), '$transaction')
          d.$transaction.active[opts.transaction.id].state = 'update'
        } else {
          Object.assign(d, u.$set || {})
        }
      })
    }

@jsreport/mingo

JavaScript implementation of MongoDB query language

MIT
Latest version published 4 years ago

Package Health Score

64 / 100
Full package analysis

Popular @jsreport/mingo functions