From 5aa1644c1c2aa35615c56291265df68c4aabef4b Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Thu, 16 May 2013 10:44:38 +0200 Subject: [PATCH] Insertion documented --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 58270e5..be09b4d 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,29 @@ It's a subset of MongoDB's API (the most used operations). The current API will var Datastore = require('nedb') , db = new Datastore('path/to/datafile'); -db.loadDatabase(callback); // Callback is optional and has signature err +db.loadDatabase(function (err) { // Callback is optional + // err is the error, if any +}); ``` ### Inserting documents -```javascript +The native types are String, Number, Boolean and Date. You can also use +arrays and subdocuments (objects). If you specify an `_id` field, it +will be used as the document's _id, otherwise a nedb will generate one. +Note the generated `_id` is a simple string, not an ObjectId. +```javascript +var document = { hello: 'world' + , n: 5 + , today: new Date() + , nedbIsAwesome: true + , fruits: [ 'apple, 'orange', 'pear' ] + , infos: { name: 'nedb' } + }; + +db.insert(document, function (err, newDoc) { // Callback is optional + // newDoc is the newly inserted document, including its _id +}); ```