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(java.util.Map<java.lang.String,?> doc)
Add a document in the form of a Map.
|
AddStatement |
add(java.lang.String... jsonStrings)
Add one or more documents.
|
Result |
addOrReplaceOne(java.lang.String id,
DbDoc doc)
Adds the document to the collection.
|
Result |
addOrReplaceOne(java.lang.String id,
java.lang.String jsonString)
Adds the document to the collection.
|
long |
count()
Query the number of documents in this collection.
|
Result |
createIndex(java.lang.String indexName,
DbDoc indexDefinition)
Create a new statement defining the creation of an index on this collection.
|
Result |
createIndex(java.lang.String indexName,
java.lang.String jsonIndexDefinition)
Create a new statement defining the creation of an index on this collection.
|
void |
dropIndex(java.lang.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(java.lang.String searchCondition)
Create a new find statement retrieving documents matching the given search condition.
|
DbDoc |
getOne(java.lang.String id)
Return the document with the given id.
|
ModifyStatement |
modify(java.lang.String searchCondition)
Create a new modify statement affecting documents matching the given search condition.
|
DbDoc |
newDoc()
Create a new document.
|
RemoveStatement |
remove(java.lang.String searchCondition)
Create a new removal statement affecting documents matching the given search condition.
|
Result |
removeOne(java.lang.String id)
Removes the document with the given id.
|
Result |
replaceOne(java.lang.String id,
DbDoc doc)
Takes in a document object that will replace the matching document.
|
Result |
replaceOne(java.lang.String id,
java.lang.String jsonString)
Takes in a document object that will replace the matching document.
|
existsInDatabase, getName, getSchema, getSession
AddStatement add(java.util.Map<java.lang.String,?> doc)
doc
- map of key-value parameters representing the document fieldsAddStatement
AddStatement add(java.lang.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(java.lang.String searchCondition)
searchCondition
- condition expressionFindStatement
ModifyStatement modify(java.lang.String searchCondition)
searchCondition
- condition expressionModifyStatement
RemoveStatement remove(java.lang.String searchCondition)
searchCondition
- condition expressionRemoveStatement
Result createIndex(java.lang.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(java.lang.String indexName, java.lang.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(java.lang.String indexName)
indexName
- index namelong count()
Result replaceOne(java.lang.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(java.lang.String id, java.lang.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(java.lang.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(java.lang.String id, java.lang.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(java.lang.String id)
id
- the document id of the document to be retrievedResult removeOne(java.lang.String id)
id
- the document id of the document to be removed