@Trait @CompileStatic trait MongoEntity<D> extends Object implements GormEntity<D>, DynamicAttributes
Enhances the default GormEntity class with MongoDB specific methods
| Type Params | Return Type | Name and description |
|---|---|---|
|
static List<D> |
aggregate(List pipeline, Function<AggregateIterable, AggregateIterable> doWithAggregate)Execute a MongoDB aggregation pipeline. |
|
static List<D> |
aggregate(List pipeline, Function<AggregateIterable, AggregateIterable> doWithAggregate, ReadPreference readPreference)Execute a MongoDB aggregation pipeline. |
|
static Number |
count(Bson filter)Counts the number of the entities in the collection. |
|
static int |
countHits(String query)Counts the number of hits |
|
static MongoCriteriaBuilder |
createCriteria()
|
|
static FindIterable<D> |
find(Bson filter)Finds all of the entities in the collection. |
|
static D |
findOneAndDelete(Bson filter)Atomically find a document and remove it. |
|
static D |
findOneAndDelete(Bson filter, FindOneAndDeleteOptions options)Atomically find a document and remove it. |
|
static MongoCollection<Document> |
getCollection()The actual collection that this entity maps to. |
|
static String |
getCollectionName()
|
|
static MongoDatabase |
getDB()
|
|
Object |
propertyMissing(String name)Allows accessing to dynamic properties with the dot operator |
|
Object |
propertyMissing(String name, Object val)Allows setting a dynamic property via the dot operator |
|
static List<D> |
search(String query, Map options)Search for entities using the given query |
|
static List<D> |
searchTop(String query, int limit, Map options)Searches for the top results ordered by the MongoDB score |
|
static String |
useCollection(String collectionName)Use the given collection for this entity for the scope of the session |
|
static String |
useDatabase(String databaseName)Use the given database for this entity for the scope of the session |
<T> |
static T |
withCollection(String collectionName, Closure<T> callable)Use the given collection for this entity for the scope of the closure call |
<T> |
static T |
withConnection(String connectionName, Closure callable)Perform an operation with the given connection |
<T> |
static T |
withDatabase(String databaseName, Closure<T> callable)Use the given database for this entity for the scope of the closure call |
Execute a MongoDB aggregation pipeline. Note that the pipeline should return documents that represent this domain class as each return document will be converted to a domain instance in the result set
pipeline - The pipelinedoWithAggregate - The function to transform the aggregate iterable (optional)Execute a MongoDB aggregation pipeline. Note that the pipeline should return documents that represent this domain class as each return document will be converted to a domain instance in the result set
pipeline - The pipelinedoWithAggregate - The function to transform the aggregate iterable (optional)Counts the number of the entities in the collection.
filter - the query filterCounts the number of hits
query - The query
Finds all of the entities in the collection.
filter - the query filterAtomically find a document and remove it.
filter - the query filter to find the document withAtomically find a document and remove it.
filter - the query filter to find the document withThe actual collection that this entity maps to.
Allows accessing to dynamic properties with the dot operator
instance - The instancename - The property nameAllows setting a dynamic property via the dot operator
instance - The instancename - The property nameval - The valueSearch for entities using the given query
query - The querySearches for the top results ordered by the MongoDB score
query - The querylimit - The maximum number of results. Defaults to 5.Use the given collection for this entity for the scope of the session
collectionName - The collection nameUse the given database for this entity for the scope of the session
databaseName - The collection nameUse the given collection for this entity for the scope of the closure call
collectionName - The collection namecallable - The callablePerform an operation with the given connection
connectionName - The name of the connectioncallable - The operation