public class Mango extends BaseMapper<MongoEntity,MongoConstraint,MongoQuery<?>> implements IndexDescription
mapper used to communicate with MongoDB.| Modifier and Type | Field and Description |
|---|---|
static String |
INDEX_ASCENDING
Defines the value used to desclare an index as sorted in ascending order.
|
static String |
INDEX_DESCENDING
Defines the value used to desclare an index as sorted in descending order.
|
mixing, VERSION| Constructor and Description |
|---|
Mango() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
createEntity(MongoEntity entity,
EntityDescriptor ed)
Creates a new entity in the underlying database.
|
void |
createIndices(com.mongodb.client.MongoDatabase client)
Invoked once the Mongo DB is first accessed and permits to create required indices.
|
protected void |
deleteEntity(MongoEntity entity,
boolean force,
EntityDescriptor ed)
Deletes the give entity from the database.
|
FilterFactory<MongoConstraint> |
filters()
Returns the filter factory which is used by this mapper.
|
protected <E extends MongoEntity> |
findEntity(E entity) |
protected <E extends MongoEntity> |
findEntity(Object id,
EntityDescriptor ed,
Function<String,sirius.kernel.commons.Value> context)
Tries to find the entity with the given id.
|
String |
getCollection(Class<? extends MongoEntity> type) |
static <E extends MongoEntity> |
make(EntityDescriptor ed,
Doc doc)
Creates a new entity for the given descriptor based on the given doc.
|
<E extends MongoEntity> |
select(Class<E> type)
Creates a query for the given type.
|
protected void |
updateEntity(MongoEntity entity,
boolean force,
EntityDescriptor ed)
Updates an existing entity in the underlying database.
|
delete, find, findOrFail, forceDelete, hasValidationWarnings, override, performDelete, performUpdate, refreshOrFail, resolve, resolveOrFail, tryDelete, tryRefresh, tryUpdate, update, validatepublic static final String INDEX_ASCENDING
public static final String INDEX_DESCENDING
protected void createEntity(MongoEntity entity, EntityDescriptor ed) throws Exception
BaseMappercreateEntity in class BaseMapper<MongoEntity,MongoConstraint,MongoQuery<?>>entity - the entity to createed - the descriptor of the entityException - in case of an database errorprotected void updateEntity(MongoEntity entity, boolean force, EntityDescriptor ed) throws Exception
BaseMapperupdateEntity in class BaseMapper<MongoEntity,MongoConstraint,MongoQuery<?>>entity - the entity to updateforce - ture if the update is forced and optimistic locking must be disableded - the descriptor of the entityException - in case of an database errorprotected void deleteEntity(MongoEntity entity, boolean force, EntityDescriptor ed) throws Exception
BaseMapperdeleteEntity in class BaseMapper<MongoEntity,MongoConstraint,MongoQuery<?>>entity - the entity to deleteforce - true if the delete is forced and optimistic locking must be disableded - the descriptor of the entityException - in case of an database errorprotected <E extends MongoEntity> Optional<E> findEntity(Object id, EntityDescriptor ed, Function<String,sirius.kernel.commons.Value> context) throws Exception
BaseMapperfindEntity in class BaseMapper<MongoEntity,MongoConstraint,MongoQuery<?>>E - the effective type of the entityid - the id of the entity to finded - the descriptor of the entity to findcontext - the advanced search context which can be populated using ContextInfo in
BaseMapper.find(Class, Object, ContextInfo...)Exception - in case of a database errorpublic static <E extends MongoEntity> E make(EntityDescriptor ed, Doc doc)
E - the effective type of the generated entityed - the descriptor of the entity to createdoc - the document to read the values fromprotected <E extends MongoEntity> Optional<E> findEntity(E entity)
findEntity in class BaseMapper<MongoEntity,MongoConstraint,MongoQuery<?>>public <E extends MongoEntity> MongoQuery<E> select(Class<E> type)
BaseMapperselect in class BaseMapper<MongoEntity,MongoConstraint,MongoQuery<?>>E - the generic type of entities to be returnedtype - the type of entities to query for.public FilterFactory<MongoConstraint> filters()
BaseMapperfilters in class BaseMapper<MongoEntity,MongoConstraint,MongoQuery<?>>public String getCollection(Class<? extends MongoEntity> type)
public void createIndices(com.mongodb.client.MongoDatabase client)
IndexDescriptioncreateIndices in interface IndexDescriptionclient - can be used to create indices in the Mongo DBCopyright © 2018. All rights reserved.