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
52
ファイル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.1k
はじめてのオンラインイベント配信 with COVID-19 バグ修正版 / Online-Event-bugfixed
moomooya
0
79
一番安い子だーれだ?~黒字化のための無慈悲なタスク配分~ / Distribute tasks
moomooya
0
2.8k
はじめてのオンラインイベント配信 with COVID-19 バグあり版 / Online-Event-includes-bug
moomooya
0
780
やはり俺の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
560
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.3k
Featured
See All Featured
Facilitating Awesome Meetings
lara
50
6.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Optimizing for Happiness
mojombo
376
70k
Music & Morning Musume
bryan
46
6.2k
Six Lessons from altMBA
skipperchong
27
3.5k
Automating Front-end Workflow
addyosmani
1366
200k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
We Have a Design System, Now What?
morganepeng
51
7.3k
Bash Introduction
62gerente
608
210k
Rails Girls Zürich Keynote
gr2m
94
13k
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ͬͯ ্खʹखΛൈ͍ͯ ॻ͖͍ͨ͜ͱ͔Βॻ͜͏ʂ
࠷ޙʹ એ͍ͤͯͩ͘͞͞
גࣜձࣾϥΫε ΤϯδχΞΛืू͍ͯ͠·͢ ʮླͷൃදΛݟͨʯ ͱ͓͍߹Θ͍ͤͩ͘͞