Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ファイルDB_NeDB_のススメ.pdf
Search
moomoo-ya
July 02, 2015
0
53
ファイルDB_NeDB_のススメ.pdf
moomoo-ya
July 02, 2015
Tweet
Share
More Decks by moomoo-ya
See All by moomoo-ya
サービスを陳腐化させない組織だった技術刷新 / Technology Renewal Initiatives
moomooya
0
1.2k
はじめてのオンラインイベント配信 with COVID-19 バグ修正版 / Online-Event-bugfixed
moomooya
0
85
一番安い子だーれだ?~黒字化のための無慈悲なタスク配分~ / Distribute tasks
moomooya
0
2.9k
はじめてのオンラインイベント配信 with COVID-19 バグあり版 / Online-Event-includes-bug
moomooya
0
790
やはり俺のLT登壇はまちがっている。 / my-lightning-talk-is-wrong-as-i-expected
moomooya
4
2.1k
Gatsby.jsで.md/.adocが混在できるテンプレートを作ったときの苦しみ / Pain-to-create-gatsby-template-that-supports-markdown-and-asciidoc
moomooya
0
570
LADRのすすめ&先行技術検証PRJの紹介 / Introducing-LADR-and-Technology-verification
moomooya
5
2.3k
技術書へのアクセスを劇的に向上させた話 / oreilly-safari-and-acm-membership
moomooya
2
7.2k
モノリスにおけるビジネスロジックの設計 ~アグリゲートパターン~ / aggregate-pattern-for-domain-modeling-on-monolithic
moomooya
2
1.4k
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
96
5.3k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
How to train your dragon (web standard)
notwaldorf
89
5.8k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
Done Done
chrislema
182
16k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
570
How to Ace a Technical Interview
jacobian
276
23k
Agile that works and the tools we love
rasmusluckow
328
21k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Building an army of robots
kneath
302
45k
Practical Orchestrator
shlominoach
186
10k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Transcript
ϑΝΠϧDB"NeDB" ͷεεϝ 2015.6.26 Isamu Suzuki Rakus co, ltd.
ླ ༐ • גࣜձࣾϥΫε • ٻॻൃߦαʔϏεΛ։ൃͯ͠·͢ • ࣄͰJavaʴJavaScriptগ͠ • ϓϥΠϕʔτJavaScriptʹશྗࢿத
• ࠷ۙPythonʹුؾͦ͠͏
ࠓͷ͓
Έͳ͞Μ
ͪΐͬͱͨ͠πʔϧΛ ࡞Δͱ͖Ͱ DB͍͍ͨͳ͊ ͱɺࢥ͏͜ͱ͋Γ·͢ΑͶʁ
Ͱ ηοτΞοϓ͕
(‘A`)ŵƃŪƄŞŤ
ͬͯͳΓ·ͤΜ͔ʁ
ͦΜͳ͋ͳͨʹ NeDB
ͬͯΔਓ Βͳ͍;Γਪ ! ͘͠ϐβͲ͏ͧ
Πϯετʔϧ npm install nedb --save ͍ͭͷҰߦʂ
ॳظԽ var NeDB = require(‘nedb'); var db = new NeDB({
filename: 'path/to/datafile' });
ॳظԽʢෳϑΝΠϧͷ߹ʣ var NeDB = require(‘nedb’); var db = {}; var
db.users = new NeDB({ filename: 'path/to/userfile' }); var db.items = new NeDB({ filename: 'path/to/itemfile' });
͍ํ(insert) db.users.insert({name: ‘hoge'}); ! //ෳϨίʔυͷૠೖ db.users.insert([ {name: 'foo'}, {name: 'bar'}
]);
͍ํ(insert) db.users.insert([ {name: 'foo'}, {name: 'bar'} ], function(err, newDoc){ //΄͛΄͛;ʔʔ
});
͍ํ(find) db.users.find({ name: 'fuga' }, function (err, docs) { //
΄͛;͕;ʔʔ }); db.users.find({ name: /f*uga/ },//ਖ਼نදݱ function (err, docs) { // ΄͛;͕;ʔʔ });
͍ํ(find & sort, skip, limit) db.users.find({ name: 'fuga' }) .sort({name:
-1}), //name߱ॱ .skip(1) //1݅Λඈͯ͠ .limit(5) //5݅औಘ .exec(function (err, docs) { // ΄͛;͕;ʔʔ });
͓͍ɺͪΐͬͱͯ
ͭ·Γ͜͏͍͏͜ͱ͔ʁ ʰզʑmongodbͱಉ͡ ߏจͰ࣮Ͱ͖Δ……ʱ
Exactly ʢͦͷͱ͓ΓͰ͍͟͝·͢ʣ ࡾ෦ऴΘΓ·ͨ͠Ͷ
͍ํ(update) db.users.update({ name: 'fuga' }, { name: 'fungaar' }, {
multi: true }, //ෳߦߋ৽ function (err, numReplaced) { // ΄͛;͕;ʔʔ });
͍ํ(remove) db.users.remove({ name: 'fuga' }, { name: 'fungaar' }, {
multi: true }, //ෳߦআ function (err, numRemoved) { // ΄͛;͕;ʔʔ });
NeDBͷAPI MongoDBͷαϒηοτ
ͭ·Γ
NeDBͰ࣮͓͚ͯ͠ MongoDBʹ ͙͢ҠߦͰ͖Δ
ͪΖΜ express-sessionͷ ηογϣϯετΞʹ connect-nedb-session-two ͱ͍͏Ϟδϡʔϧ͕͋Γ·͢
݁
NeDBͬͯ ্खʹखΛൈ͍ͯ ॻ͖͍ͨ͜ͱ͔Βॻ͜͏ʂ
࠷ޙʹ એ͍ͤͯͩ͘͞͞
גࣜձࣾϥΫε ΤϯδχΞΛืू͍ͯ͠·͢ ʮླͷൃදΛݟͨʯ ͱ͓͍߹Θ͍ͤͩ͘͞