-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnedbtest.js
More file actions
35 lines (32 loc) · 782 Bytes
/
nedbtest.js
File metadata and controls
35 lines (32 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* @Author: harryfeng
* @Date: 2017-10-02 10:33:52
* @Last Modified by: harryfeng
* @Last Modified time: 2017-10-02 10:38:50
*/
var Datastore = require('nedb'),
db = new Datastore({
filename: 'nedb_test.db',
autoload: true
});
var doc = {
hello: 'world',
n: 5,
today: new Date(),
nedbIsAwesome: true,
notthere: null,
notToBeSaved: undefined // Will not be saved
,
fruits: ['apple', 'orange', 'pear'],
infos: {
name: 'nedb'
}
};
db.insert(doc, function(err, newDoc) {
console.log(err);
// newDoc is the newly inserted document, including its _id
// newDoc has no key called notToBeSaved since its value was undefined
});
db.count({}, function (err, count) {
console.log(count);
});