Removed useless persistWholeDatabase

pull/2/head
Louis Chatriot 12 years ago
parent 31babe2327
commit c816affc68
  1. 29
      lib/datastore.js
  2. 3
      lib/model.js

@ -171,35 +171,6 @@ Datastore.prototype.findOne = function (query, callback) {
}; };
/**
* Persist the whole database
* @param {Array} data Optional data to persist. If not set, we use the database data
* @param {Function} cb Optional callback, signature: err
*/
Datastore.prototype.persistWholeDatabase = function (data, cb) {
var callback
, self = this
, newContents = '';
if (!data) {
data = self.data;
}
if (typeof data === 'function') {
cb = data;
data = self.data;
}
callback = cb || function () {};
data.forEach(function (d) {
newContents += model.serialize(d) + '\n';
});
fs.writeFile(self.filename, newContents, 'utf8', callback);
};
/** /**
* Persist new state for the given newDocs (can be update or removal) * Persist new state for the given newDocs (can be update or removal)
* @param {Array} newDocs Can be empty if no doc was updated/removed * @param {Array} newDocs Can be empty if no doc was updated/removed

@ -55,6 +55,9 @@ function checkObject (obj) {
/** /**
* Serialize an object to be persisted to a one-line string * Serialize an object to be persisted to a one-line string
* For serialization/deserialization, we use the native JSON parser and not eval or Function
* That gives us less freedom but data entered in the database may come from users
* so eval and the like are not safe
* Accepted primitive types: Number, String, Boolean, Date, null * Accepted primitive types: Number, String, Boolean, Date, null
* Accepted secondary types: Objects, Arrays * Accepted secondary types: Objects, Arrays
*/ */

Loading…
Cancel
Save