Skip to content

Commit

Permalink
add nedb demo
Browse files Browse the repository at this point in the history
  • Loading branch information
fasionchan committed Nov 6, 2019
1 parent ff0a937 commit 13a39d0
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/database/nedb/demo/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
var NeDB = require('nedb')

var db = new NeDB({
filename: './user.db',
autoload: true,
})

db.insert({
name: 'Alice',
age: 20,
rank: 1,
}, function(err, doc) {
console.log('inserted:', doc)
})

db.find({
name: 'Alice',
}, function(err, docs) {
console.log('Alice found:', docs)
})

db.update({
name: 'Alice',
}, {
$set: {
age: 21,
},
}, function(err, n) {
console.log('docs updated:', n)
})

db.find({
name: 'Alice',
}, function(err, docs) {
console.log('Alice changed:', docs)
})

db.remove({
name: 'Alice',
}, function(err, n) {
console.log('docs deleted:', n)
})

0 comments on commit 13a39d0

Please sign in to comment.