fireblade
Posts: 4
Joined: Wed Jan 14, 2015 10:07 pm

Database to Node.js

Wed Mar 30, 2016 11:23 pm

I'm developing a web node.js app to run in raspberry pi, and I need a database to store users and other data.
I was thinking to use mongodb, but I saw that the new version doesn't run in raspberry pi because the 32 bit version was deprecated.
I would like to know, in your opinion, what is the best database to install in raspberry pi to use with node.js.

Thanks :)

Heater
Posts: 19296
Joined: Tue Jul 17, 2012 3:02 pm

Re: Database to Node.js

Thu Mar 31, 2016 9:55 am

The is no "best database". The selection of a database will depend on what you want to use it for. How much data it needs to hold. How fast do you want to update and/or query it. What kind of data, a times series log or some complex relational thing or what? What kind of queries do you want to make.

For relational data I would stick with the tried and trusted MySql or SqlLite.

I don't like messing with SQL much so for lesser structured data I like RethinkDB

https://rethinkdb.com/blog/temperature- ... ide-of-pi/

But that's just me.

I would not keep a database on a Pi's SD card. Better to a lot of reading and writing to a USB hard drive or flash stick.

If you are dealing with users, usernames, passwords then I would consider having letting a service like stormpath.com handle the login, logout, signup, stuff and take care of keeping passwords securely. Assuming your Pi will have net access when in use.
Slava Ukrayini.

User avatar
DougieLawson
Posts: 42328
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: Database to Node.js

Fri Apr 01, 2016 5:26 am

MySQL (use the MariaDB version), SQLite3 or IBM's Informix. All three are well supported. Which you choose depends on the amount of data, whether the SQL engine includes the functions you need and how you're going to access it (for example do you need jdbc and/or odbc).
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

Heater
Posts: 19296
Joined: Tue Jul 17, 2012 3:02 pm

Re: Database to Node.js

Fri Apr 01, 2016 11:16 am

It's just that if you are working in node.js it becomes massively simpler to just use Javascript objects (JSON) in a noSql database.

So if you don't need a relational database, ACID compliance and all that nosql can make life much easier.
Slava Ukrayini.

Rogueninja64
Posts: 6
Joined: Sat Dec 15, 2012 9:43 pm
Location: Minnesota, USA

Re: Database to Node.js

Mon Apr 04, 2016 2:31 am

As someone that uses quite a bit of Node and used my Pi as a web server for ages I did use MongoDB for a little while. It works really well. I ended up going back to SQL as I just preferred it over NoSQL. MySQL or PostgreSQL are both good choices. I currently use PostgreSQL for my apps. Node has a few great modules for both Databases.

RogueAfterlife
Posts: 4
Joined: Sun Apr 17, 2016 5:57 pm

Re: Database to Node.js

Sun Apr 17, 2016 6:03 pm

I think that instead of installing a DB on the pi itself, you should consider using a DBaaS e.g, modulus.net for MongoDB. I have used modulus in the past for my other non-IOT NodeJS projects with great success. They have a free tier that is great! Obviously, the pi must be connected to the internet to access the DB. I also agree that if you're looking for auth that you should consider stormpath.

rnbwd
Posts: 6
Joined: Fri Mar 20, 2015 8:15 pm

Re: Database to Node.js

Mon May 09, 2016 10:26 pm

Using JSON and functional libraries like LoDash or even immutable objects like in Mori or Immutable have served me very well for apps running like in kiosks and stuff. I'm under the impression databases are only necessary for production stuff at this point, i mean unless you're filtering 100,000's of lines of JSON it won't make a difference, you just have to learn how to code it manually, which I personally find easier than reading the documentation for a database. There's also the level-up movement which kinda cool. But other that - rethink is prob the best 'db' for raspi I've seen tutorials on it. You could also use this https://github.com/mafintosh/mongojs

Heater
Posts: 19296
Joined: Tue Jul 17, 2012 3:02 pm

Re: Database to Node.js

Tue May 10, 2016 6:49 am

rnbwd,

You really are confusing concerns there:

JSON is a human readable text based format for representing data. Like XML, CSV and many others. It can be used to store data in files, or in database records, as a format for exchanging data between machines and so on. JSON is nice and easy to work with, unlike XML. Especially in Javascript as it is basically a direct textual representation of JS objects.

Immutable data structures as provided by libraries like, well, Immutable are a means of implementing a functional programming style.

Databases are for long term storage of perhaps a large amount of data. Long term as in the data survives longer than the run time of any program writing and reading it. Large as in there maybe a lot more data than fits in the memory space available to any running program. Databases also allow for many instances of software to access the same data. A database could be as simple as a file or as complex as Oracle.

JSON, Immutable and databases address different problems.

JSON - A data representation.
Immutable - A programming style.
Database - storage

Whether you need anyone of them or not depends what you want to do.

I do agree, databases like LevelUp and Rethink are really nice. So simple. Unless you need the functionality of a relational database.
Slava Ukrayini.

Return to “Other programming languages”