@groovy.transform.Trait @groovy.transform.CompileStatic trait MongoEntity<D> extends java.lang.Object implements DynamicAttributes, GormEntity<D>
Enhances the default GormEntity class with MongoDB specific methods
| Type Params | Return Type | Name and description |
|---|---|---|
|
static java.util.List<D> |
aggregate(java.util.List pipeline, java.util.function.Function<AggregateIterable, AggregateIterable> doWithAggregate)Execute a MongoDB aggregation pipeline. |
|
static java.util.List<D> |
aggregate(java.util.List pipeline, java.util.function.Function<AggregateIterable, AggregateIterable> doWithAggregate, ReadPreference readPreference)Execute a MongoDB aggregation pipeline. |
|
static java.lang.Number |
count(Bson filter)Counts the number of the entities in the collection. |
|
static int |
countHits(java.lang.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 java.lang.String |
getCollectionName()
|
|
static MongoDatabase |
getDB()
|
|
Document |
getDbo()Return the DBObject instance for the entity |
|
java.lang.Object |
propertyMissing(java.lang.String name)Allows accessing to dynamic properties with the dot operator |
|
java.lang.Object |
propertyMissing(java.lang.String name, java.lang.Object val)Allows setting a dynamic property via the dot operator |
|
static java.util.List<D> |
search(java.lang.String query, java.util.Map options)Search for entities using the given query |
|
static java.util.List<D> |
searchTop(java.lang.String query, int limit, java.util.Map options)Searches for the top results ordered by the MongoDB score |
|
static java.lang.String |
useCollection(java.lang.String collectionName)Use the given collection for this entity for the scope of the session |
|
static java.lang.String |
useDatabase(java.lang.String databaseName)Use the given database for this entity for the scope of the session |
<T> |
static T |
withCollection(java.lang.String collectionName, groovy.lang.Closure<T> callable)Use the given collection for this entity for the scope of the closure call |
<T> |
static T |
withConnection(java.lang.String connectionName, groovy.lang.Closure callable)Perform an operation with the given connection |
<T> |
static T |
withDatabase(java.lang.String databaseName, groovy.lang.Closure<T> callable)Use the given database for this entity for the scope of the closure call |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
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.
Return the DBObject instance for the entity
instance - The instanceAllows 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 operationUse the given database for this entity for the scope of the closure call
databaseName - The collection namecallable - The callable