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
Rails Girls Zürich Keynote
gr2m
94
13k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Agile that works and the tools we love
rasmusluckow
328
21k
Facilitating Awesome Meetings
lara
51
6.2k
KATA
mclloyd
29
14k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.5k
We Have a Design System, Now What?
morganepeng
51
7.3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
570
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Visualization
eitanlees
146
15k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
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ͬͯ ্खʹखΛൈ͍ͯ ॻ͖͍ͨ͜ͱ͔Βॻ͜͏ʂ
࠷ޙʹ એ͍ͤͯͩ͘͞͞
גࣜձࣾϥΫε ΤϯδχΞΛืू͍ͯ͠·͢ ʮླͷൃදΛݟͨʯ ͱ͓͍߹Θ͍ͤͩ͘͞