reduxdb
v3.1.0
Published
Redux with MongoDB-like API.
Downloads
22
Readme
reduxdb
Redux with MongoDB-like API.
Notice that NOT all the features of MongoDB are implemented here, such as multi-index and query operators.
The purpose of reduxdb is to avoid writing almost the same actions and stores again and again in different projects.
Installation
npm install --save reduxdb
Usage
var reduxdb = require("reduxdb")
var db = reduxdb.use("test")
db.createCollection("users", {index: "id"})
db.createCollection("teams", {index: "id"})
db.createCollection("books") // using default index `_id`
db.subscribe(function() {
console.log(db.stats())
console.log(db.users.stats())
console.log(db.teams.stats())
console.log(db.books.stats())
})
db.users.insert({id: "1234", name: "wizawu"})
db.users.findOne({name: "wizawu"}).id // 1234
API
reduxdb
- use(name)
reduxdb.DB
createCollection(name, options)
options
can be only used to define index, for exampledb.createCollection("user", {index: "uid"})
reduxdb.Collection
Only support Query for Equality, for example
// Return all users matching {"age": 18, "name": {"first": "Andrew"}} db.user.find({"age": 18, "name.first": "Andrew"})
Same
query
type asfind()
.getDB()
getFullName()
getIndexKeys()
getName()
No
options
supported here.Same
query
type asfind()
.update(query, update, options)
Same
query
type asfind()
.upsert
andmulti
are supported inoptions
.