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
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.
Related
Previous answers to this question:
Difference between MongoDB and Mongoose
Why do we need, what advantages to use mongoose
The main reason given in these answers is "schemas". Since 3.6, mongodb has introduced its own schemas:
https://docs.mongodb.com/manual/core/schema-validation/
These are more thorough and work by default on inserts and updates.
Are there any more significant reasons to use Mongoose, as that was the main one and now it seems to have been integrated into the native API. I have also noticed that mongoose is lacking various new features implemented in mongodb.
Mongoose, the driver I'm using right now, is much more intuitive to learn if you're a beginner. Many criticize the mongoose because they claim that the creation of collection schemes is the opposite of what was thought of the mongodb and NoSQL databases; However I think that even using the native mongoDB driver you will always have to create a minimum of schematics, even for validation and have an idea of what you are entering in the database. Mangusta is extremely convenient because in addition to allowing the creation of templates, it is possible to declare methods in the document and control events. In addition, the mongoose automatically performs additional validation, and has many more search functions. The real negative point of the mongoose is performance. (On this page there is the difference in performance of the two drivers https://medium.com/#bugwheels94/performance-difference-in-mongoose-vs-mongodb-60be831c69ad)
Naturally all these characteristics of the mongoose abandon the performance.
It's hard to give you a driver because it's based on the kind of project you have in mind.
I am using Apache Solr 6.3.0 and MongoDB 3.4 for advance text search features. I have successfully, synced mongodb with solr cores using mongo-connector 2.5 and solr doc manager.
I want to know the right way and practices to use solr with mongo and I have some issues that I need help on:
1). Now that my data is available both in mongo database and also indexed and stored in Solr cores, should I now query Solr all the time ? Or should I query solr for text search only and perform rest of the queries on mongo ?
2). Is there some way I could perform powerful search directly on mongo database using the indexing done by Solr ?
3). I have some collections that contain deeply nested json data and MongoDb supports them well. Solr indexes and stores such data in flattened form.But, I want to maintain the original nested json format in query response. Is this something I can achieve with Solr ?
Other suggestions about good practices of using solr with mongoDb will be extremely helpful.
If it makes sense to just query Solr, do that. If it makes sense to query Solr for certain data, do that. It depends on your use case, but if any query can be answered with the data in Solr, it's perfectly fine to use that for everything. That'll probably allow a more efficient use of your caches.
No, not that I know of.
Not really. Solr isn't well suited for nested JSON (even if you have parent/child documents, it's something you'll have to manually handle in every situation and will require special casing all over).
In those situations you can use Solr for querying, get the ids back and then retrieve the actual documents from mongo with their JSON structure intact. In that case you can leave most fields as non-stored in Solr.
What I've understood, sails binds collection with its Models. Is there a way i can create a collection on runtime. What i want to do is create a different collection for each user. something like (user_12345, unique for every user).
I've tried waterline and sails-mongo, They allow me to query collections for CRUD operation. but I couldn't understand how to create a new collection using sails-mongo or waterline library. Please help.
Waterline doesn't provide a way to create arbitrary collections in Mongo. The ORM's job is to map the logical models in your app to collections (or tables, or whatever) in your database. It's not clear what you're trying to accomplish by giving each user their own collection, but if it's truly necessary you can still achieve it by just making the raw Mongodb driver a dependency in your project:
npm install --save mongodb
and following the documentation for connecting and creating collections. You won't be able to use Waterline to work with those collections, though; you'll have to use native operations for all inserting, querying, etc.
I am experimenting a lot these days, and one of the things I wanted to do is combine two popular NoSQL databases, namely Neo4j and MongoDB. Simply because I feel they complement eachother perfectly. The first class citizens in Neo4j, the relations, are imo exactly what's missing in MongoDB, whereas MongoDb allows me to not put large amounts of data in my node properties.
So I am trying to combine the two in a Java application, using the Neo4j Java REST binding, and the MongoDB Java driver. All my domain entities have a unique identifier which I store in both databases. The other data is stored in MongoDB and the relations between entities are stored in Neo4J. For instance, both databases contain a userid, MongoDB contains the profile information, and Neo4J contains friendship relations. With the custom data access layer I have written, this works exactly like I want it to. And it's fast.
BUT... When I want to create a user, I need to create both a node in Neo4j and a document in MongoDB. Not necessarily a problem, except that Neo4j is transactional and MongoDB is not. If both were transactional, I would just roll back both transactions when one of them fails. But since MongoDB isn't transactional, I cannot do this.
How do I ensure that whenever I create a user, either both a Node and Document are created, or none of both. I don't want to end up with a bunch of documents that have no matching node.
On top of that, not only do I want my combined database interaction to be ACID compliant, I also want it to be threadsafe. Both the GraphDatabaseService and the MongoClient / DB are provided from singletons.
I found something about creating "Transaction Documents" in MongoDB, but I realy don't like that approach. I would like something nice and clean like the neo4j beginTx, tx.success, tx.failure, tx.finish setup. Ideally, something I can implement in the same try/catch/finally block.
Should I perhaps make a switch to CouchDB, which does appear to be transactional?
Edit : After some more research, sparked by a comment, I came to realize that CouchDB is also not suitable for my specific needs. To clarify, the Neo4j part is set in stone. The Document Store database is not as long as it has a Java Library.
Pieter-Jan,
if you are able to use Neo4j 2.0 you can implement a Schema-Index-Provider (which is really easy) that creates your documents transactionally in MongoDB.
As Neo4j makes its index providers transactional (since the beginning), we did that with Lucene and there is one for Redis too (needs to be updated). But it is much easier with Neo4j 2.0, if you want to you can check out my implementation for MapDB. (https://github.com/jexp/neo4j-mapdb-index)
Although I'm a huge fan of both technologies, I think a better option for you could be OrientDB. It's a graph (as Neo4) and document (as MongoDB) database in one and supports ACID transactions. Sounds like a perfect match for your needs.
As posted here https://stackoverflow.com/questions/23465663/what-is-the-best-practice-to-combine-neo4j-and-mongodb?lq=1, you might have a look on Structr.
Its backend can be regarded as a Document database around Neo4j. It's fully transactional and open-source.
What are comparable database like Mongo DB?
We are trying to evaluate Mongo DB and find the best database for a enterprise level application.
Is there any developer UI and admin UI available for MongoDB like SQL Plus/Toad etc for Oracle?
MongoDB is a document-oriented database, so instead of a row of data, you have a document. In MonogDB's case, its a JSON document. Apache's CouchDB is another document database that stores data in JSON format although there are subtle differences between the two.
Choosing between the two depends on your use case. Sometimes CouchDB is better than MongoDB.
Checkout this comparative to see the differences.
MongoDB is what is known as a NoSQL database, which is I assume why you're interested in it. You can find a list of other NoSQL databases at the below links:
http://en.wikipedia.org/wiki/NoSQL
http://nosql-database.org/
MongoDB does not include a GUI-style administrative interface; however, there are numerous community projects that provide admin UIs for MongoDB:
http://www.mongodb.org/display/DOCS/Admin+UIs
I like document oriented databases like MongoDB very much. Because they are shema-less. You can just insert find and update your records without first having to define a schema. But you can define one in your own Project logic. You have more freedom.
It would be nice to have an embeddable NoSQL database. Like SQLite but document oriented.
Currently I do develop one in Java. (You can also use it withhin an Android App):
https://github.com/neo-expert/thingdb
I am quite happy with MongoVue. I've made a couple of videos about this here.