ReactiveMongo is an extremely convenient toolkit for working with MongoDB in Scala applications. But, at the same time, its documentation does not cover some of the typical scenarios, so sometimes it takes time to find the right solution. One of such tasks - storing polymorphic objects in a database - is the focus of this blog post.
Usually a data access object for MongoDB consists of common routine CRUD methods. Those methods should be implemented, tested, maintained just like any other code. In this post, I'm going to show you how to use
SalatDAO to vastly simplify the process.
Generally, Salat is used for serialization of case classes, enums and collections to
The database query log could be a crucial part of a database restoring process required after data corruption caused by either an illegal update operation or a damage of database files. The main task here is to find the right format for storing the queries.
Java driver for MongoDB does not provide any utility classes that could help with building update queries. If you want to create a query to update or increment field values, you usually have to use
BasicDBObjectBuilder. This is intuitive approach, but queries defined in such a way are quite hard to read and maintain.
There is some twist to use more specific data storage engines than RDBMS. The mongodb is a modern feature-rich non-RDBMS database. It can be used with grails quite well, though some special care should be taken. In this post we will create base secure grails application powered by mongodb.
If you are going to use mongodb for production grails application you might stuck with the issue that replica set is really not supported by current version 1.0.0.M1 of mongodb plugin.
It is quite surprising because mongo java driver supports replica set configuration quite fine.
The problem is that GORM plugin is built on top of version 0.5.1 of gmongo library which doesn't support replica set. Only current development version 0.7 of gmongo library supports this feature.