Update README.md

pull/2/head
Louis Chatriot 12 years ago
parent b1abd34384
commit 055b6a09c7
  1. 9
      README.md

@ -33,6 +33,7 @@ It's a subset of MongoDB's API (the most used operations). The current API will
You can use NeDB as an in-memory only datastore or as a persistent datastore. One datastore is the equivalent of a MongoDB collection. The constructor is used as follows `new Datastore(options)` where `options` is an object with the following fields: You can use NeDB as an in-memory only datastore or as a persistent datastore. One datastore is the equivalent of a MongoDB collection. The constructor is used as follows `new Datastore(options)` where `options` is an object with the following fields:
* `filename` (optional): path to the file where the data is persisted. If left blank, the datastore is automatically considered in-memory only. * `filename` (optional): path to the file where the data is persisted. If left blank, the datastore is automatically considered in-memory only.
* `nodeWebkitAppName` (optional): if you are using NeDB from whithin a Node Webkit app, specify its name (the same one you use in the `package.json`) in this field and the `filename` will be relative to the directory Node Webkit uses to store the rest of the application's data (local storage etc.)
* `inMemoryOnly` (optional, defaults to false): as the name implies. * `inMemoryOnly` (optional, defaults to false): as the name implies.
* `pipeline` (optional, defaults to false): use pipelining. This is an experimental feature that speeds up writes (about 2x) but can sometime increase read times. You probably shouldn't use it yet. * `pipeline` (optional, defaults to false): use pipelining. This is an experimental feature that speeds up writes (about 2x) but can sometime increase read times. You probably shouldn't use it yet.
@ -43,7 +44,13 @@ var Datastore = require('nedb')
// Persistent datastore // Persistent datastore
var Datastore = require('nedb') var Datastore = require('nedb')
, db = new Datastore({ filename: 'path/to/datafile' }); , db = new Datastore({ filename: 'path/to/datafile' });
// Persistent datastore for a Node Webkit app called 'nwtest'
// For example on Linux, the datafile will be ~/.config/nwtest/nedb-data/something.db
var Datastore = require('nedb')
, db = new Datastore({ filename: 'something.db', nodeWebkitAppName: 'nwtest' });
db.loadDatabase(function (err) { // Callback is optional db.loadDatabase(function (err) { // Callback is optional
// err is the error, if any // err is the error, if any
}); });

Loading…
Cancel
Save