1

Can I use mongoengine or djongo for ODM and pymongo for interaction with the db?

I've read these two about something related to my question:

Insert data by pymongo using mongoengine ORM in pyramid

Use MongoEngine and PyMongo together

But, I couldn't find what I'm looking for (I guess). So here's what I'm trying to find:

¿Does this practice affect the performance of my application? ¿How well recommended is it?

So, if it is recommended, and everything is right, ¿Do I need to put an extra layer of security or something?, because, I want to build an API using the serializations for models that django-rest-framework-mongoengine offers, and then do what I have to do in the view of the API endpoint.

It could be djongo or something like it, what I want is just an ODM for serializing, define a structure for the API and so on, use pymongo for queries, cause according to what I've been reading, mongoengine could make slower the interaction with the db

esteban21
  • 139
  • 9

1 Answers1

2

The term "ORM" does not apply to MongoDB since MongoDB is non-relational. The proper term is "ODM" - object-document mapper.

Generally, a MongoDB ODM is built on top of a MongoDB driver. The functionalities of the ODM and the driver are complementary - the driver provides low-level database access and the ODM provides high-level features like schema, associations, callbacks.

If you want to use the high-level features, it makes sense to use an ODM. If you don't need any of those features and just want to perform basic CRUD operations, using a driver directly is more efficient. Some applications use both of these strategies depending on the operation that needs to be performed.

D. SM
  • 13,584
  • 3
  • 12
  • 21
  • I understand, I got wrong with that term, but it is still not clear for me, should I use it or not?, I mean, potentially, there could be more than CRUD operations, also, I'm having some trouble understanding the drf request handling, because I'm not sure if I could use mongod within an API that could have thousands of requests, and well, I'm not sure if will ended up working with multi threading or something like that – esteban21 Apr 29 '20 at 06:04
  • 1
    I suggest building a working application using either option first. Chances are your first application will be just fine either way. – D. SM Apr 29 '20 at 06:14