If no filename is specified, an in-memory only datastore is created

pull/2/head
Louis Chatriot 12 years ago
parent c9cba88a80
commit afe3bfa6d4
  1. 7
      lib/datastore.js
  2. 2
      package.json

@ -202,6 +202,9 @@ Datastore.prototype._loadDatabase = function (cb) {
, self = this , self = this
; ;
// In-memory only datastore
if (!self.filename) { return callback(); }
customUtils.ensureDirectoryExists(path.dirname(self.filename), function (err) { customUtils.ensureDirectoryExists(path.dirname(self.filename), function (err) {
fs.exists(self.filename, function (exists) { fs.exists(self.filename, function (exists) {
if (!exists) { if (!exists) {
@ -302,6 +305,9 @@ Datastore.prototype.persistNewState = function (newDocs, cb) {
, callback = cb || function () {} , callback = cb || function () {}
; ;
// In-memory only datastore
if (!self.filename) { return callback(); }
self.datafileSize += newDocs.length; self.datafileSize += newDocs.length;
newDocs.forEach(function (doc) { newDocs.forEach(function (doc) {
@ -519,5 +525,4 @@ Datastore.prototype.remove = function () {
module.exports = Datastore; module.exports = Datastore;

@ -1,6 +1,6 @@
{ {
"name": "nedb", "name": "nedb",
"version": "0.6.0", "version": "0.6.1",
"author": { "author": {
"name": "tldr.io", "name": "tldr.io",
"email": "hello@tldr.io" "email": "hello@tldr.io"

Loading…
Cancel
Save