public interface Collection extends DatabaseObject
DatabaseObject.DbObjectStatus, DatabaseObject.DbObjectType
Modifier and Type | Method and 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, getSession
AddStatement add(Map<String,?> doc)
doc
- map of key-value parameters representing the document fieldsAddStatement
AddStatement add(String... jsonStrings)
jsonStrings
- one or more documents given as JSON stringsAddStatement
AddStatement add(DbDoc document)
document
- DbDoc
AddStatement
AddStatement add(DbDoc... documents)
documents
- one or more documents given as DbDoc
AddStatement
FindStatement find()
FindStatement
FindStatement find(String searchCondition)
searchCondition
- condition expressionFindStatement
ModifyStatement modify(String searchCondition)
searchCondition
- condition expressionModifyStatement
RemoveStatement remove(String searchCondition)
searchCondition
- condition expressionRemoveStatement
Result 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:
Result
Result 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:
Result
void 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