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
72
一番安い子だーれだ?~黒字化のための無慈悲なタスク配分~ / 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
2k
Gatsby.jsで.md/.adocが混在できるテンプレートを作ったときの苦しみ / Pain-to-create-gatsby-template-that-supports-markdown-and-asciidoc
moomooya
0
550
LADRのすすめ&先行技術検証PRJの紹介 / Introducing-LADR-and-Technology-verification
moomooya
5
2.2k
技術書へのアクセスを劇的に向上させた話 / oreilly-safari-and-acm-membership
moomooya
2
7.1k
モノリスにおけるビジネスロジックの設計 ~アグリゲートパターン~ / aggregate-pattern-for-domain-modeling-on-monolithic
moomooya
2
1.3k
Featured
See All Featured
A Tale of Four Properties
chriscoyier
156
23k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
What's in a price? How to price your products and services
michaelherold
243
12k
The Cult of Friendly URLs
andyhume
78
6k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Rails Girls Zürich Keynote
gr2m
94
13k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
GitHub's CSS Performance
jonrohan
1030
460k
Navigating Team Friction
lara
183
14k
Building Applications with DynamoDB
mza
90
6.1k
Happy Clients
brianwarren
98
6.7k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
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ͬͯ ্खʹखΛൈ͍ͯ ॻ͖͍ͨ͜ͱ͔Βॻ͜͏ʂ
࠷ޙʹ એ͍ͤͯͩ͘͞͞
גࣜձࣾϥΫε ΤϯδχΞΛืू͍ͯ͠·͢ ʮླͷൃදΛݟͨʯ ͱ͓͍߹Θ͍ͤͩ͘͞