public class CollectionImpl extends java.lang.Object implements Collection
DatabaseObject.DbObjectStatus, DatabaseObject.DbObjectType
Modifier and Type | Method and Description |
---|---|
AddStatement |
add(DbDoc... docs)
Add a sequence of documents.
|
AddStatement |
add(DbDoc doc)
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... jsonString)
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.
|
boolean |
equals(java.lang.Object other) |
DatabaseObject.DbObjectStatus |
existsInDatabase()
Query the existence of this database object.
|
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.
|
java.lang.String |
getName()
Retrieve the name of the database object represented by the Java object.
|
DbDoc |
getOne(java.lang.String id)
Return the document with the given id.
|
Schema |
getSchema()
Retrieve the schema owning this database object.
|
Session |
getSession()
Retrieve the session owning the given schema object.
|
int |
hashCode() |
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.
|
java.lang.String |
toString() |
public Session getSession()
DatabaseObject
getSession
in interface DatabaseObject
Session
public Schema getSchema()
DatabaseObject
getSchema
in interface DatabaseObject
Schema
public java.lang.String getName()
DatabaseObject
getName
in interface DatabaseObject
public DatabaseObject.DbObjectStatus existsInDatabase()
DatabaseObject
existsInDatabase
in interface DatabaseObject
DatabaseObject.DbObjectStatus
public AddStatement add(java.util.Map<java.lang.String,?> doc)
Collection
add
in interface Collection
doc
- map of key-value parameters representing the document fieldsAddStatement
public AddStatement add(java.lang.String... jsonString)
Collection
add
in interface Collection
jsonString
- one or more documents given as JSON stringsAddStatement
public AddStatement add(DbDoc doc)
Collection
add
in interface Collection
doc
- DbDoc
AddStatement
public AddStatement add(DbDoc... docs)
Collection
add
in interface Collection
docs
- one or more documents given as DbDoc
AddStatement
public FindStatement find()
Collection
find
in interface Collection
FindStatement
public FindStatement find(java.lang.String searchCondition)
Collection
find
in interface Collection
searchCondition
- condition expressionFindStatement
public ModifyStatement modify(java.lang.String searchCondition)
Collection
modify
in interface Collection
searchCondition
- condition expressionModifyStatement
public RemoveStatement remove(java.lang.String searchCondition)
Collection
remove
in interface Collection
searchCondition
- condition expressionRemoveStatement
public Result createIndex(java.lang.String indexName, DbDoc indexDefinition)
Collection
Example: collection.createIndex("myIndex", "{\"fields\": [{\"field\": \"$.myGeoJsonField\", \"type\": \"GEOJSON\", \"required\": true, \"options\": 2, \"srid\": 4326}], \"type\":\"SPATIAL\"}");
createIndex
in interface Collection
indexName
- index nameindexDefinition
- JSON document with the following fields:
Result
public Result createIndex(java.lang.String indexName, java.lang.String jsonIndexDefinition)
Collection
Example: collection.createIndex("myIndex", "{\"fields\": [{\"field\": \"$.myGeoJsonField\", \"type\": \"GEOJSON\", \"required\": true, \"options\": 2, \"srid\": 4326}], \"type\":\"SPATIAL\"}");
createIndex
in interface Collection
indexName
- index namejsonIndexDefinition
- JSON document with the following fields:
Result
public void dropIndex(java.lang.String indexName)
Collection
dropIndex
in interface Collection
indexName
- index namepublic long count()
Collection
count
in interface Collection
public DbDoc newDoc()
Collection
newDoc
in interface Collection
DbDoc
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public Result replaceOne(java.lang.String id, DbDoc doc)
Collection
replaceOne
in interface Collection
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.public Result replaceOne(java.lang.String id, java.lang.String jsonString)
Collection
replaceOne
in interface Collection
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.public Result addOrReplaceOne(java.lang.String id, DbDoc doc)
Collection
addOrReplaceOne
in interface Collection
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.public Result addOrReplaceOne(java.lang.String id, java.lang.String jsonString)
Collection
addOrReplaceOne
in interface Collection
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.public DbDoc getOne(java.lang.String id)
Collection
getOne
in interface Collection
id
- the document id of the document to be retrievedpublic Result removeOne(java.lang.String id)
Collection
removeOne
in interface Collection
id
- the document id of the document to be removed