|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Datastore
Datastore interface to get/delete/save objects
Method Summary | ||
---|---|---|
AggregationPipeline |
createAggregation(Class source)
Returns a new query bound to the kind (a specific DBCollection ) |
|
|
createQuery(Class<T> kind)
Returns a new query bound to the kind (a specific DBCollection ) |
|
|
createUpdateOperations(Class<T> kind)
The builder for all update operations |
|
|
delete(Class<T> clazz,
Iterable<V> ids)
Deletes the given entities (by id) |
|
|
delete(Class<T> clazz,
V id)
Deletes the given entity (by id) |
|
|
delete(Query<T> q)
Deletes the given entities based on the query |
|
|
delete(Query<T> q,
WriteConcern wc)
Deletes the given entities based on the query, with the WriteConcern |
|
|
delete(T entity)
Deletes the given entity (by @Id) |
|
|
delete(T entity,
WriteConcern wc)
Deletes the given entity (by @Id), with the WriteConcern |
|
void |
ensureCaps()
ensure capped DBCollections for Entity (s) |
|
|
ensureIndex(Class<T> clazz,
String fields)
Ensures (creating if necessary) the index including the field(s) + directions; eg fields = "field1, -field2" ({field1:1, field2:-1}) |
|
|
ensureIndex(Class<T> clazz,
String name,
String fields,
boolean unique,
boolean dropDupsOnCreate)
Ensures (creating if necessary) the index including the field(s) + directions; eg fields = "field1, -field2" ({field1:1, field2:-1}) |
|
void |
ensureIndexes()
Ensures (creating if necessary) the indexes found during class mapping (using @Indexed, @Indexes) |
|
void |
ensureIndexes(boolean background)
Ensures (creating if necessary) the indexes found during class mapping (using @Indexed, @Indexes) , possibly in the
background |
|
|
ensureIndexes(Class<T> clazz)
Ensures (creating if necessary) the indexes found during class mapping (using @Indexed, @Indexes) |
|
|
ensureIndexes(Class<T> clazz,
boolean background)
Ensures (creating if necessary) the indexes found during class mapping (using @Indexed, @Indexes) , possibly in the
background |
|
Key<?> |
exists(Object keyOrEntity)
Does a query to check if the keyOrEntity exists in mongodb |
|
|
find(Class<T> clazz)
Find all instances by type |
|
|
find(Class<T> clazz,
String property,
V value)
Find all instances by collectionName, and filter property. |
|
|
find(Class<T> clazz,
String property,
V value,
int offset,
int size)
Find all instances by collectionName, and filter property. |
|
|
findAndDelete(Query<T> q)
Deletes the given entities based on the query (first item only). |
|
|
findAndModify(Query<T> q,
UpdateOperations<T> ops)
Find the first Entity from the Query, and modify it. |
|
|
findAndModify(Query<T> q,
UpdateOperations<T> ops,
boolean oldVersion)
Find the first Entity from the Query, and modify it. |
|
|
findAndModify(Query<T> q,
UpdateOperations<T> ops,
boolean oldVersion,
boolean createIfMissing)
Find the first Entity from the Query, and modify it. |
|
|
get(Class<T> clazz,
Iterable<V> ids)
Find the given entities (by id); shorthand for find("_id in", ids) |
|
|
get(Class<T> clazz,
V id)
Find the given entity (by id); shorthand for find("_id ", id) |
|
|
get(T entity)
Find the given entity (by collectionName/id); think of this as refresh |
|
|
getByKey(Class<T> clazz,
Key<T> key)
Find the given entity (by collectionName/id); |
|
|
getByKeys(Class<T> clazz,
Iterable<Key<T>> keys)
Find the given entities (by id), verifying they are of the correct type; shorthand for find("_id in", ids) |
|
|
getByKeys(Iterable<Key<T>> keys)
Find the given entities (by id); shorthand for find("_id in", ids) |
|
DBCollection |
getCollection(Class<?> c)
|
|
|
getCount(Class<T> clazz)
Gets the count this kind ( DBCollection ) |
|
|
getCount(Query<T> query)
Gets the count of items returned by this query; same as query.countAll() |
|
|
getCount(T entity)
Gets the count this kind ( DBCollection ) |
|
DB |
getDB()
|
|
WriteConcern |
getDefaultWriteConcern()
|
|
|
getKey(T entity)
Creates a (type-safe) reference to the entity; if stored this will become a DBRef |
|
MongoClient |
getMongo()
Get the underlying MongoClient that allows connection to the MongoDB instance being used. |
|
QueryFactory |
getQueryFactory()
Returns the current QueryFactory . |
|
|
mapReduce(MapreduceType type,
Query q,
Class<T> outputType,
MapReduceCommand baseCommand)
Runs a map/reduce job at the server; this should be used with a server version 1.7.4 or higher |
|
|
mapReduce(MapreduceType type,
Query q,
String map,
String reduce,
String finalize,
Map<String,Object> scopeFields,
Class<T> outputType)
Runs a map/reduce job at the server; this should be used with a server version 1.7.4 or higher |
|
|
merge(T entity)
Work as if you did an update with each field in the entity doing a $set; Only at the top level of the entity. |
|
|
merge(T entity,
WriteConcern wc)
Work as if you did an update with each field in the entity doing a $set; Only at the top level of the entity. |
|
|
queryByExample(T example)
Returns a new query based on the example object |
|
|
save(Iterable<T> entities)
Saves the entities (Objects) and updates the @Id field |
|
|
save(Iterable<T> entities,
WriteConcern wc)
Saves the entities (Objects) and updates the @Id field, with the WriteConcern |
|
|
save(T... entities)
Saves the entities (Objects) and updates the @Id field |
|
|
save(T entity)
Saves the entity (Object) and updates the @Id field |
|
|
save(T entity,
WriteConcern wc)
Saves the entity (Object) and updates the @Id field, with the WriteConcern |
|
void |
setDefaultWriteConcern(WriteConcern wc)
|
|
void |
setQueryFactory(QueryFactory queryFactory)
Replaces the current QueryFactory with the given value. |
|
|
update(Key<T> key,
UpdateOperations<T> ops)
updates the entity with the operations; this is an atomic operation |
|
|
update(Query<T> query,
UpdateOperations<T> ops)
updates all entities found with the operations; this is an atomic operation per entity |
|
|
update(Query<T> query,
UpdateOperations<T> ops,
boolean createIfMissing)
updates all entities found with the operations, if nothing is found insert the update as an entity if "createIfMissing" is true; this is an atomic operation per entity |
|
|
update(Query<T> query,
UpdateOperations<T> ops,
boolean createIfMissing,
WriteConcern wc)
|
|
|
update(T ent,
UpdateOperations<T> ops)
updates the entity with the operations; this is an atomic operation |
|
|
updateFirst(Query<T> query,
T entity,
boolean createIfMissing)
updates the first entity found with the operations, if nothing is found insert the update as an entity if "createIfMissing" is true; this is an atomic operation per entity |
|
|
updateFirst(Query<T> query,
UpdateOperations<T> ops)
updates the first entity found with the operations; this is an atomic operation |
|
|
updateFirst(Query<T> query,
UpdateOperations<T> ops,
boolean createIfMissing)
updates the first entity found with the operations, if nothing is found insert the update as an entity if "createIfMissing" is true; this is an atomic operation per entity |
|
|
updateFirst(Query<T> query,
UpdateOperations<T> ops,
boolean createIfMissing,
WriteConcern wc)
|
Method Detail |
---|
<T> Key<T> getKey(T entity)
DBRef
Key<?> exists(Object keyOrEntity)
<T,V> WriteResult delete(Class<T> clazz, V id)
<T,V> WriteResult delete(Class<T> clazz, Iterable<V> ids)
<T> WriteResult delete(Query<T> q)
<T> WriteResult delete(Query<T> q, WriteConcern wc)
<T> WriteResult delete(T entity)
<T> WriteResult delete(T entity, WriteConcern wc)
<T> Query<T> find(Class<T> clazz)
<T,V> Query<T> find(Class<T> clazz, String property, V value)
Find all instances by collectionName, and filter property.
This is the same as: find(clazzOrEntity).filter
(property, value);
<T,V> Query<T> find(Class<T> clazz, String property, V value, int offset, int size)
Find all instances by collectionName, and filter property.
This is the same as: find(clazzOrEntity).filter
(property, value).offset(offset).limit(size);
<T,V> Query<T> get(Class<T> clazz, Iterable<V> ids)
find("_id in", ids)
<T,V> T get(Class<T> clazz, V id)
find("_id ", id)
<T> T get(T entity)
<T> List<T> getByKeys(Class<T> clazz, Iterable<Key<T>> keys)
find("_id in", ids)
<T> List<T> getByKeys(Iterable<Key<T>> keys)
find("_id in", ids)
<T> T getByKey(Class<T> clazz, Key<T> key)
<T> long getCount(T entity)
DBCollection
)
<T> long getCount(Class<T> clazz)
DBCollection
)
<T> long getCount(Query<T> query)
query.countAll()
<T> Iterable<Key<T>> save(Iterable<T> entities)
<T> Iterable<Key<T>> save(Iterable<T> entities, WriteConcern wc)
<T> Iterable<Key<T>> save(T... entities)
<T> Key<T> save(T entity)
<T> Key<T> save(T entity, WriteConcern wc)
<T> Key<T> merge(T entity)
<T> Key<T> merge(T entity, WriteConcern wc)
<T> UpdateResults update(T ent, UpdateOperations<T> ops)
<T> UpdateResults update(Key<T> key, UpdateOperations<T> ops)
<T> UpdateResults update(Query<T> query, UpdateOperations<T> ops)
<T> UpdateResults update(Query<T> query, UpdateOperations<T> ops, boolean createIfMissing)
<T> UpdateResults update(Query<T> query, UpdateOperations<T> ops, boolean createIfMissing, WriteConcern wc)
<T> UpdateResults updateFirst(Query<T> query, UpdateOperations<T> ops)
<T> UpdateResults updateFirst(Query<T> query, UpdateOperations<T> ops, boolean createIfMissing)
<T> UpdateResults updateFirst(Query<T> query, UpdateOperations<T> ops, boolean createIfMissing, WriteConcern wc)
<T> UpdateResults updateFirst(Query<T> query, T entity, boolean createIfMissing)
<T> T findAndDelete(Query<T> q)
<T> T findAndModify(Query<T> q, UpdateOperations<T> ops)
<T> T findAndModify(Query<T> q, UpdateOperations<T> ops, boolean oldVersion)
q
- the query to find the Entity with; You are not allowed to offset/skip in the query.oldVersion
- indicated the old version of the Entity should be returned
<T> T findAndModify(Query<T> q, UpdateOperations<T> ops, boolean oldVersion, boolean createIfMissing)
q
- the query to find the Entity with; You are not allowed to offset/skip in the query.oldVersion
- indicated the old version of the Entity should be returnedcreateIfMissing
- if the query returns no results, then a new object will be created (sets upsert=true)
<T> MapreduceResults<T> mapReduce(MapreduceType type, Query q, String map, String reduce, String finalize, Map<String,Object> scopeFields, Class<T> outputType)
T
- The type of resulting dataoutputType
- The type of resulting data; inline is not working yettype
- MapreduceTypeq
- The query (only the criteria, limit and sort will be used)map
- The map function, in javascript, as a stringreduce
- The reduce function, in javascript, as a stringfinalize
- The finalize function, in javascript, as a string; can be nullscopeFields
- Each map entry will be a global variable in all the functions; can be null
<T> MapreduceResults<T> mapReduce(MapreduceType type, Query q, Class<T> outputType, MapReduceCommand baseCommand)
T
- The type of resulting datatype
- MapreduceTypeq
- The query (only the criteria, limit and sort will be used)outputType
- The type of resulting data; inline is not working yetbaseCommand
- The base command to fill in and send to the server
<T> UpdateOperations<T> createUpdateOperations(Class<T> kind)
AggregationPipeline createAggregation(Class source)
DBCollection
)
<T> Query<T> createQuery(Class<T> kind)
DBCollection
)
<T> Query<T> queryByExample(T example)
<T> void ensureIndex(Class<T> clazz, String fields)
<T> void ensureIndex(Class<T> clazz, String name, String fields, boolean unique, boolean dropDupsOnCreate)
void ensureIndexes()
@Indexed, @Indexes)
void ensureIndexes(boolean background)
@Indexed, @Indexes)
, possibly in the
background
<T> void ensureIndexes(Class<T> clazz)
@Indexed, @Indexes)
<T> void ensureIndexes(Class<T> clazz, boolean background)
@Indexed, @Indexes)
, possibly in the
background
void ensureCaps()
Entity
(s)
DB getDB()
MongoClient getMongo()
DBCollection getCollection(Class<?> c)
WriteConcern getDefaultWriteConcern()
void setDefaultWriteConcern(WriteConcern wc)
void setQueryFactory(QueryFactory queryFactory)
QueryFactory
with the given value.
QueryFactory
QueryFactory getQueryFactory()
QueryFactory
.
QueryFactory
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |