0.1.2 • Published 9 years ago

mongocache v0.1.2

Weekly downloads
2
License
ISC
Repository
github
Last release
9 years ago

mongocache

Gets ALL documents (only selected keys) from MongoDB and keeps them updated with oplog. Also indexes collections, providing instantenous queries. Uses native MongoDB client, so it's superfast.

Especially useful if need to maintain and query complex tree hierarchies.

installation

npm install mongocache --save

usage

var mongocache = require('mongocache')
var dbcache = mongocache({
  dbname: {
    levels: {
      select: '_id parent name', // only keep these keys
      index: 'parent' // index 'parent' -value
    }
  }
})

setInterval(function () {
  // get all docs
  dbcache.dbname.levels.getAll(function (docs) {
      console.log(docs)
  })
  // find by _id
  dbcache.dbname.levels.findById('507f1f77bcf86cd799439011', function (doc) {
      console.log(doc)
  })
  // find by indexed key ('parent' === '507f1f77bcf86cd799439011')
  dbcache.dbname.levels.find('parent', '507f1f77bcf86cd799439011', function (docs) {
      console.log(docs)
  })
  // find first by indexed key ('parent' === '507f1f77bcf86cd799439011')
  dbcache.dbname.levels.findOne('parent', '507f1f77bcf86cd799439011', function (doc) {
      console.log(doc)
  })
}, 1000)
0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.2

9 years ago