Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORM Bookshelf + postgresql or MongoDB database in nodejs?

I need to choose between two databases. In one approach, it will store relational data, but to work with it I want to use Bookshelf ORM. In other way, I can use MongoDB, and store data as an object with no need to use ORM to use data as an object.

So, which is preferred with CRUD approach?

The application is designed to be as fast as possible.

Data sample:

{
  "ownedBy": "(someProjectID)",
  "keyword": "node",
  "references": [
    {
      "type": "post",
      "groupId": -1478414,
      "messageId": 14578,
      "text": "Node.js is great language!"
    },
    {
      "type": "comment",
      "groupId": -1478414,
      "messageId": 744114,
      "text": "Yeah, I agree. Node is very flexible"
    }
  ]
}
like image 835
BadVolt Avatar asked Dec 04 '25 02:12

BadVolt


1 Answers

In this situation , We can touch some points with asking following use cases.

  • Do you need static schemes ?
  • Do you need data constraints ?
  • Do you need complex and strong (sql-like)query language ?
  • Do you need integrate your db easily with other data store systems ?
  • Do you need to struggle with foreign keys, table relations, complex joins ?
  • Do you need stored procedures ?

If that questions' answer is no , you should select MongoDB.

Then ;

  • You will be able to develop faster your application.
  • You will be able to take advantages of tons of resources about node.js and mongoDb.
  • You will only have dynamic schemes(collections->documents).
  • You will handle complex joins easily with nested documents in mongodb if you need joins etc.
  • You will write javascript and create json-like documents and create query as json as well. Also this situation will affect your development time positively.

So use cases can be changed according to requirements. In this case you want faster development, and also just create a CRUD application with node.js. I advice to you MongoDB. Good luck.

like image 67
İlker Korkut Avatar answered Dec 05 '25 16:12

İlker Korkut



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!