Can ReactiveMongo can be used in Lagom framework? - mongodb

I need to convert a existing Play + Scala + Mongodb application into Lagom micro services. But all the examples I have tested were using Cassadra.
There is Read Support for mongodb, as mentioned in their documentation.
There is plugin too.
This means, can we not write into mongodb collections?

Yes, you notionally can create a MongoDB persistence API. You'll need to implement:
com.lightbend.lagom.scaladsl.persistence.{
PersistenceComponents,
PersistentEntityRegistry,
ReadSidePersistenceComponents,
WriteSidePersistenceComponents
}
and play.api.db.DBComponents.
You can see an example implementation here for JDBC.

Related

How to read and write from MongoDb using two different drivers (MongoDB Scala Driver and Salat)

We want to change our MongoDB driver overtime to MongoDB Scala Driver, but we using Salat and it reads and writes sealed classes and ADTs using "_typeHint" to the DB. The MongoDB Scala Driver reads and writes sealed classes and ADTs using "_t", What we want is a way to read and write "_typeHint" using MongoDB Scala Driver? We know we need a custom codec, but not sure how to implement it.
We want the ability to support both drivers until we remove Salat.
Thanks.
This appears to be described here. See "annotation convention" and "bson discriminator".

Data-modelling tools for MongoDB

Even though MongoDB is a schema-less DB but there is a requirement in my project where I have to map my classes to the Database objects and prefer to have the data modelling for the same. Please suggest some Data-modelling tools for MongoDB to map the DB to Classes and Objects.
Moon Modeler is a data modeling tool for MongoDB and Mongoose (ODM)
I think you want to model your applications and persist your data in MongoDB. So it depends on what framework/language are you using for application.
I did a quick web search to get these ODM (Object-Document-Mapper) options recommended to work with MongoDB for some of the popular languages.
ruby
https://docs.mongodb.com/mongoid/master/
http://mongomapper.com/
java
https://github.com/mongodb/morphia
http://hibernate.org/ogm/
python
http://mongoengine.org/
http://api.mongodb.com/python/1.6/index.html

MongoDB document to POJO

I'm using allanbank async driver for operations on mongodb. Is there any api available through which I can convert returned Document to a POJO, like we can do in spring driver available for mongodb
You could use morphia (which would mean using mongodb's java driver, or you could use jackson to map back to your POJOs.
You can use Spring Data , it includes integrated object mapping between documents and POJOs.
I wanted something for async driver as well. As MongoDB came with Codec Feature in 3.0 version (both sync and async version of driver), it's not neccessary to use libraries such as Morphia anymore so I wrote simple library for mapping POJO into MongoDB myself.
in Spring Data MongoDB you can use
#Autowired
MongoConverter mongoConverter;
Then
TARGET_OBJECT = mongoConverter.read(YOUR_TARGET.class, YOUR_DOCUMENT);

Play Framework 2.2 Java with MongoDB

what's the best way to use MongoDB with PlayFramework 2.2 Java? Is there one that allows me to use the javax.persistence.Entity annotation?
Thanks!
What about an ORM for Mongodb ?
Reading this http://www.infoq.com/articles/mongodb-java-orm-bcd
I never used it but it seems that MJORM could do what you want :
http://code.google.com/p/mongo-java-orm/source/browse/trunk/src/main/java/com/googlecode/mjorm/?r=3180

mongodb persistence patterns for JSON client app, jackson mapper or morphia driver?

I've started a new job where they are using mongodb in a java environment.
They have implemented a pattern using DTOs and factories with the morphia driver, this may be due to a migration onto mongodb from a key value store previously. The client is a JSON client.
It seems to me that the jackson-mongo-mapper would be a better approach because it's just mapping pojos from json to BSON and back, seems like it could do away with all DTO factory facade?
Anyone know any pros and cons with these different approaches?
Spring Data for Mongodb is very nice since you can use even another data store or mix them and repository interface is very helpful.
Kundera is an option through JPA2
http://agilemobiledeveloper.wordpress.com/2013/08/22/working-with-mongodb-using-kundera/
There's a lot of java to mongodb options.
http://www.agilemobiledeveloper.com/2013/01/31/hibernate-ogm-mongodb-vs-kundera-vs-jongo-vs-mongodb-api-vs-morphia-vs-spring-data-mongo-mongodb-drivers-for-java/
Adding your own data layer and making sure you use DI and test it fully is very helpful.
NOSQLUnit is awesome -> https://github.com/lordofthejars/nosql-unit
DTOs are good for keeping a separation between implementation and design, so when they need or want to switch from mongo to some other NoSQL or SQL database it can be done cleanly.