Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NeDB Support #170

Open
mindjuice opened this issue Apr 7, 2019 · 5 comments
Open

NeDB Support #170

mindjuice opened this issue Apr 7, 2019 · 5 comments

Comments

@mindjuice
Copy link

Is your feature request related to a problem? Please describe.
For smaller projects where a full mongodb server is overkill, it would be great to use rest-hapi with NeDB: https://github.com/louischatriot/nedb

Describe the solution you'd like
Rather than providing a mongo URI, we could pass in an object that maps model name keys to NeDB datastore instances (i.e., mongo collections).

Describe alternatives you've considered
TingoDB, but it appears to be abandoned.

Additional context
I haven't looked in detail yet to see if rest-hapi uses any parts of the mongo API that NeDB does not support.

If this seems possible, I can help with the code changes.

@mindjuice
Copy link
Author

mindjuice commented Apr 8, 2019

Looks like this might already be possible by passing in a mongoose instance to the options object that is wrapped by NeDB:

https://github.com/aerys/mongoose-nedb
https://github.com/aerys/mongoose-nedb/blob/master/lib/connection.js
https://github.com/aerys/mongoose-nedb/blob/master/lib/collection.js

That package does not seem active/supported though.

Hopefully it supports enough of the MongoDB API to be useful.

@JKHeadley
Copy link
Owner

I love this idea! It does look like NeDB isn't very actively supported, though it might be worth looking into.

Another possible alternative if you just want an in-memory db is https://github.com/nodkz/mongodb-memory-server, though it is mostly meant for testing purposes.

You can see it in use in the rest-hapi e2e tests:

const MongoMemoryServer = require('mongodb-memory-server').MongoMemoryServer

@mindjuice
Copy link
Author

For my use case, I need persistence (it's for a small, Raspberry-Pi-like device), and data would be streaming in quite frequently. If I can get 2GB of RAM onto the unit I might be confident enough to just use MongoDB directly. Worried about the overhead of MongoDB on one hand, and whether NeDB would be up to the task on the other hand.

@JKHeadley
Copy link
Owner

Yeah that makes total sense. Just curious, if you could choose your ideal DB for your application, what would it be? I would like to one day update rest-hapi to support multiple DBs.

@mindjuice
Copy link
Author

I've mainly used MongoDB and MariaDB/MySQL, but I also really liked RethinkDB before the company went under. I sort of lost hope for it, but it looks like the community has kept it up pretty well though.

It has the ability to stream updates to queries in real-time as the database changes, which is really slick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants