public interface Collection extends DatabaseObject
DatabaseObject.DbObjectStatus, DatabaseObject.DbObjectType| Modifier and Type | Method | Description |
|---|---|---|
AddStatement |
add(DbDoc... documents) |
Add a sequence of documents.
|
AddStatement |
add(DbDoc document) |
Add a document in the form of a DbDoc.
|
AddStatement |
add(Map<String,?> doc) |
Add a document in the form of a Map.
|
AddStatement |
add(String... jsonStrings) |
Add one or more documents.
|
Result |
addOrReplaceOne(String id,
DbDoc doc) |
Adds the document to the collection.
|
Result |
addOrReplaceOne(String id,
String jsonString) |
Adds the document to the collection.
|
long |
count() |
Query the number of documents in this collection.
|
Result |
createIndex(String indexName,
DbDoc indexDefinition) |
Create a new statement defining the creation of an index on this collection.
|
Result |
createIndex(String indexName,
String jsonIndexDefinition) |
Create a new statement defining the creation of an index on this collection.
|
void |
dropIndex(String indexName) |
Create a new statement defining the removal of an index on this collection.
|
FindStatement |
find() |
Create a new find statement retrieving all documents in the collection.
|
FindStatement |
find(String searchCondition) |
Create a new find statement retrieving documents matching the given search condition.
|
DbDoc |
getOne(String id) |
Return the document with the given id.
|
ModifyStatement |
modify(String searchCondition) |
Create a new modify statement affecting documents matching the given search condition.
|
DbDoc |
newDoc() |
Create a new document.
|
RemoveStatement |
remove(String searchCondition) |
Create a new removal statement affecting documents matching the given search condition.
|
Result |
removeOne(String id) |
Removes the document with the given id.
|
Result |
replaceOne(String id,
DbDoc doc) |
Takes in a document object that will replace the matching document.
|
Result |
replaceOne(String id,
String jsonString) |
Takes in a document object that will replace the matching document.
|
existsInDatabase, getName, getSchema, getSessionAddStatement add(Map<String,?> doc)
doc - map of key-value parameters representing the document fieldsAddStatementAddStatement add(String... jsonStrings)
jsonStrings - one or more documents given as JSON stringsAddStatementAddStatement add(DbDoc document)
document - DbDocAddStatementAddStatement add(DbDoc... documents)
documents - one or more documents given as DbDocAddStatementFindStatement find()
FindStatementFindStatement find(String searchCondition)
searchCondition - condition expressionFindStatementModifyStatement modify(String searchCondition)
searchCondition - condition expressionModifyStatementRemoveStatement remove(String searchCondition)
searchCondition - condition expressionRemoveStatementResult createIndex(String indexName, DbDoc indexDefinition)
Example: collection.createIndex("myIndex", "{\"fields\": [{\"field\": \"$.myGeoJsonField\", \"type\": \"GEOJSON\", \"required\": true, \"options\": 2, \"srid\": 4326}], \"type\":\"SPATIAL\"}");
indexName - index nameindexDefinition - JSON document with the following fields:
ResultResult createIndex(String indexName, String jsonIndexDefinition)
Example: collection.createIndex("myIndex", "{\"fields\": [{\"field\": \"$.myGeoJsonField\", \"type\": \"GEOJSON\", \"required\": true, \"options\": 2, \"srid\": 4326}], \"type\":\"SPATIAL\"}");
indexName - index namejsonIndexDefinition - JSON document with the following fields:
Resultvoid dropIndex(String indexName)
indexName - index namelong count()
Result replaceOne(String id, DbDoc doc)
id - the document id of the document to be replaceddoc - the new document, which may contain expressions. If document contains an _id value, it is ignored.Result replaceOne(String id, String jsonString)
id - the document id of the document to be replacedjsonString - the new document, given as JSON string, which may contain expressions. If document contains an _id value, it is ignored.Result addOrReplaceOne(String id, DbDoc doc)
id - the document id of the document to be replaceddoc - the new document, which may contain expressions. If doc contains an _id value and it does not match the given id then the error
will be thrown.Result addOrReplaceOne(String id, String jsonString)
id - the document id of the document to be replacedjsonString - the new document, given as JSON string, which may contain expressions. If doc contains an _id value and it does not match the given id then
the error will be thrown.DbDoc getOne(String id)
id - the document id of the document to be retrieved