I was following the below guidelines to implement MongoDB ORM in my Quarkus server app.
QUARKUS - SIMPLIFIED MONGODB WITH PANACHE
https://quarkus.io/guides/mongodb-panache
How can I achieve document reference with this?
For example: If I have 2 entities like Employee, Organisation then how can I refer Organisation in my Employee entity?
Quarkus MongoDB with Panache didn't offers specific support for dbref.
You may be able to use a field of type com.mongodb.DBRef but we will not automatically load the document referenced by it so you need to do it by yourself.
Related
I am developing a SaaS application with Spring data and Mongo data with multitenancy on the schema level. So, separation is done on each collection. Each collection has tenant_id.
I managed to implement with Mongo template plus query but in that case, I lose repository abstraction.
What I can not find is how to extend repositories and use all the functions from repository API and add for each query type (find, save, update..) tenant_id in the query?
I would like to create collection where only one entity should be stored.
Questions:
Is it possible to create restrictions for this collection on db level?
What are the best practices for CRUD application dealing with such collection?
You can use schema validation to be sure that new documents will respect your schema. This feature appears in 3.2, but was modified since 3.6 with use of JSON schema. Check the right doc version.
I'm newbie in mongo database ,I want to know if can create database and tables with hibernate.hbm2ddl.auto values create,update,validate.I created Documents classes but Database didn't created.
Well, you cannot use the regular hibernate with NoSQL DBs like MongoDB. You can try Hibernate OGM or Morphia. Personally, I have used Morphia and it does it's job.
Morphia - https://github.com/mongodb/morphia
I assume you use Hibernate OGM to access MongoDB. In this case specify the following property to have the database automatically created:
hibernate.ogm.datastore.create_database=true
You can find a list with all available options in the reference guide. You also might be interested in issue OGM-571 which is about honoring the existing hbm2ddl setting.
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 would like to use Silex with MongoDB.
I guess the best way is to use a Silex Extension that again uses the Doctrine MongoDB libs.
There are two Silex Extensions right now that seem to provide this functionality.
https://github.com/fate/Silex-Extensions
and
https://github.com/docteurklein/SilexExtensions
Except that the first brings more other Extensions and the second uses submodules (which i would prefer) instead of vendors.sh, are there more things to take care of?
Can anybody recommend the one or the other?
Update:
The Extensions below are outdated, pls use answer above.
to answer it myself:
https://github.com/fate/Silex-Extensions uses the Doctrine MongoDB Abstraction Layer
whereas
https://github.com/docteurklein/SilexExtensions uses the Doctrine MongoDB ODM (Object Document Mapper)
So with the first you can only query MongoDB through Doctrine and with the second you can persist Model Objects to MongoDB as known from f.e. symfony models.
This are brand new MongoDB providers with multi connection support.
MongoDB:
https://github.com/saxulum/saxulum-doctrine-mongodb-provider
MongoDB ODM:
https://github.com/saxulum/saxulum-doctrine-mongodb-odm-provider