why the use of an ORM with NoSql (like MongoDB) [closed] why the use of an ORM with NoSql (like MongoDB) [closed] mongodb mongodb

why the use of an ORM with NoSql (like MongoDB) [closed]


Firstly, they are not ORM (since they don't have any relations among them), they are ODM (Object Document Mapper)

Main usage of these ODM frameworks here same as the some common feature of ORM, thus

  • providing the abstraction over your data model. you can have your data modelled in your application irrespective of the target software.
  • Most ODM's build to leverage the existing language features and use the familiar pattern to manipulate data instead to learn new language syntax's of the new software.

When i use mongoid (Ruby ODM for mongo), i can query mongo the way i do it in active model (mostly).

Since they don't have the relation among them, these ODM's provide the way to define the relations in your models and simulate the relationships. These are all abstracted from the developer so they can code the same way they do with the relational data.


ORM is an abstraction layer. Switching to a different engine is much easier when the queries are abstracted away, and hidden behind a common interface (it doesn't always work that well in practice, but it's still easier than without).


Interesting question. Although NoSQL databases do not have a mechanism to identify relationships, it does not mean that there are no logical relationships between the data that you are storing. Most of the time, you are handling & enforcing those relationships in code manually if you're using a NoSQL database.

Hence, I feel that ORMs can still help you here. If you do have data that is related, but need to use a NoSQL database, an ORM can still help you in maintaining clean data.

For Example, I use Amazon SimpleDB for the lower cost, but my data still has relationships, which need to be maintained. Currently, I'm doing that manually. Maybe an ORM would help me as well.