blob: d0c7a87cf954890269b227a4382927f37fcc2eaf [file] [log] [blame]
In addition to storing dynamic attributes, as of version 1.3.0 of the plugin you can also switch which database and/or collection to persist to at runtime.
For example:
{code}
Person.withDatabase("administrators") {
new Person(name:"Bob").save()
}
{code}
The above example will save a @Person@ instance to the 'administrators' database. The database is used for the scope of the closure. You can switch database for the scope of the active session:
{code}
Person.useDatabase("administrators")
new Person(name:"Bob").save()
{code}
In addition, there are equivalent @withCollection@ and @useCollection@ methods for switching collection at runtime.