Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ファイルDB_NeDB_のススメ.pdf

moomoo-ya
July 02, 2015
52

 ファイルDB_NeDB_のススメ.pdf

moomoo-ya

July 02, 2015
Tweet

More Decks by moomoo-ya

Transcript

  1. ॳظԽʢෳ਺ϑΝΠϧͷ৔߹ʣ var NeDB = require(‘nedb’); var db = {}; var

    db.users = new NeDB({ filename: 'path/to/userfile' }); var db.items = new NeDB({ filename: 'path/to/itemfile' });
  2. ࢖͍ํ(find) db.users.find({ name: 'fuga' }, function (err, docs) { //

    ΄͛;͕;ʔ͹ʔ }); db.users.find({ name: /f*uga/ },//ਖ਼نදݱ function (err, docs) { // ΄͛;͕;ʔ͹ʔ });
  3. ࢖͍ํ(find & sort, skip, limit) db.users.find({ name: 'fuga' }) .sort({name:

    -1}), //name߱ॱ .skip(1) //1݅໨Λඈ͹ͯ͠ .limit(5) //5݅औಘ .exec(function (err, docs) { // ΄͛;͕;ʔ͹ʔ });
  4. ࢖͍ํ(update) db.users.update({ name: 'fuga' }, { name: 'fungaar' }, {

    multi: true }, //ෳ਺ߦߋ৽ function (err, numReplaced) { // ΄͛;͕;ʔ͹ʔ });
  5. ࢖͍ํ(remove) db.users.remove({ name: 'fuga' }, { name: 'fungaar' }, {

    multi: true }, //ෳ਺ߦ࡟আ function (err, numRemoved) { // ΄͛;͕;ʔ͹ʔ });