////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////

If a domain class has no specify Mongo client connection configuration then the default is used.

You can set the `connection` method in the `mapping` block to configure an alternate Mongo Client.

For example, if you want to use the `ZipCode` domain to use a Mongo client connection called `'lookup'`, configure it like this:

[source,groovy]
----
class ZipCode {

   String code

   static mapping = {
      connection 'lookup'
   }
}
----

A domain class can also use two or more configured Mongo client connections by using the `connections` method with a list of names to configure more than one, for example:

[source,groovy]
----
class ZipCode {

   String code

   static mapping = {
      connections(['lookup', 'auditing'])
   }
}
----

If a domain class uses the default connection and one or more others, you can use the `ConnectionSource.DEFAULT` constant to indicate that:

[source,groovy]
----
import org.grails.datastore.mapping.core.connections.*

class ZipCode {

   String code

   static mapping = {
      connections(['lookup', ConnectionSource.DEFAULT])
   }
}
----

If a domain class uses all configured `DataSource` instances use the value `ALL`:

[source,groovy]
----
import org.grails.datastore.mapping.core.connections.*

class ZipCode {

   String code

   static mapping = {
      connection ConnectionSource.ALL
   }
}
----

