Summary

Persists Joda Time types to a Mongo database (using mongodb)

Installation

grails install-plugin mongo-jodatime

Description

Grails Mongo Joda Time GORM Support Plugin

Introduction

This is a plugin that works with the Grails MongoDB GORM plugin to allow you to persist and work with Joda Time objects in your Mongo database. By default, the MongoDB plugin can persist java.util.Date objects, which are mostly deprecated and a general pain to use.

Design goals

Querying

We don't want this:

class DomainClass {
Date someDate //ugh, Date objects are a pain!
}

We would like this:

class DomainClass {
DateTime someDate //yay, Joda Time is useful!
}

And then we'd like to be able to be able to do queries like this:

//Find by using Joda Time objects
DomainClass.findBySomeDate(new DateTime())

//Find by comparing different Joda Time objects to each other
DomainClass.findAll{ someDate == new LocalDate()}

Persistence

We want the plugin to lay out our date objects in such a way that they're easy to query from outside the Grails environment. And, this aspect should eventually be configurable.

Here is how the above DomainClass currently looks when it is persisted:

This plugin currently supports persisting and querying these Joda Time objects:

DateTime

Interval

LocalDate

LocalDateTime

It is currently possible to query any of the above objects using any of the other above objects.

It is reasonably straightforward to add further support, but time and budgetary constraints prevent us (Spantree (+)) from doing so at this point. We will add features as we need them or if any pull requests come in.