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
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Speed Design
sergeychernyshev
25
620
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
The Cult of Friendly URLs
andyhume
78
6k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
900
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Producing Creativity
orderedlist
PRO
341
39k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
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ͬͯ ্खʹखΛൈ͍ͯ ॻ͖͍ͨ͜ͱ͔Βॻ͜͏ʂ
࠷ޙʹ એ͍ͤͯͩ͘͞͞
גࣜձࣾϥΫε ΤϯδχΞΛืू͍ͯ͠·͢ ʮླͷൃදΛݟͨʯ ͱ͓͍߹Θ͍ͤͩ͘͞