0.3.0 • Published 6 years ago

json-datastore v0.3.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

json-datastore

File-based JSON datastore.

Install

$ npm install --save json-datastore

Usage

let datastore = require("json-datastore")

// Write to a datastore
datastore.write("/path/to/datastore", {
  _id: "global-config", checkUpdates: false
}).then(doNextThing)

// Write to users collection
datastore.write("/path/to/datastore/users", {
  _id: 1, name: "Steve"
}).then(doNextThing)

// Read by id in users collection
datastore.read("/path/to/datastore/users", {_id: 1}).then(user => {
  doNextThing(user)
})

// Read all in users collection
datastore.read("/path/to/datastore/users").then(users => {
  doNextThing(users)
})

// Read all in users collection in descending order
datastore.read("/path/to/datastore/users", {}, {
  descending: true
}).then(users => {
  doNextThing(users)
})

// Remove all in users collection
datastore.remove("/path/to/datastore/users").then(doNextThing)

API

datastore.read(path, query, options) Read one or many documents in the specified path.

datastore.write(path, object, options) Write object to a JSON file in the specified path. An _id is generated by default for the object and used as the file name. You can partition the store by writing to sub-directories.

datastore.remove(path, query) Remove one or many documents in the specified path.

License

MIT License

0.3.0

6 years ago

0.2.0

6 years ago

0.1.7

6 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago