|
|
|
@ -493,5 +493,61 @@ db.insert({ tag: ['a', 'b', 'c'] }, function () { |
|
|
|
|
}); |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
var db = new Datastore({ inMemoryOnly: true }); |
|
|
|
|
|
|
|
|
|
db.ensureIndex({ fieldName: 'a', unique: true }); |
|
|
|
|
|
|
|
|
|
db.insert({ a: 4 }, function () { |
|
|
|
|
db.insert({ a: 5 }, function () { |
|
|
|
|
db.insert({ a: 6 }, function () { |
|
|
|
|
|
|
|
|
|
db.find({}, function (err, docs) { |
|
|
|
|
console.log(docs); |
|
|
|
|
|
|
|
|
|
db.update({}, { $set: { a: 42 } }, { multi: true }, function (err) { |
|
|
|
|
console.log(err); |
|
|
|
|
|
|
|
|
|
db.find({}, function (err, docs) { |
|
|
|
|
// FAIL
|
|
|
|
|
// The first document was modified and the modification was not roll back when the
|
|
|
|
|
// unique constraint was triggered on the second modif
|
|
|
|
|
console.log(docs); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
var db = new Datastore({ inMemoryOnly: true }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.insert({ a: [4] }, function () { |
|
|
|
|
db.insert({ a: [5] }, function () { |
|
|
|
|
db.insert({ a: 6 }, function () { |
|
|
|
|
|
|
|
|
|
db.find({}, function (err, docs) { |
|
|
|
|
console.log(docs); |
|
|
|
|
|
|
|
|
|
db.update({}, { $push: { a: 42 } }, { multi: true }, function (err) { |
|
|
|
|
console.log(err); |
|
|
|
|
|
|
|
|
|
db.find({}, function (err, docs) { |
|
|
|
|
console.log(docs); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = Datastore; |