类 CollectionImpl
- java.lang.Object
-
- com.mysql.cj.xdevapi.CollectionImpl
-
- 所有已实现的接口:
Collection,DatabaseObject
public class CollectionImpl extends Object implements Collection
-
-
嵌套类概要
-
从接口继承的嵌套类/接口 com.mysql.cj.xdevapi.DatabaseObject
DatabaseObject.DbObjectStatus, DatabaseObject.DbObjectType
-
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 AddStatementadd(DbDoc doc)Add a document in the form of a DbDoc.AddStatementadd(DbDoc... docs)Add a sequence of documents.AddStatementadd(String... jsonString)Add one or more documents.AddStatementadd(Map<String,?> doc)Add a document in the form of a Map.ResultaddOrReplaceOne(String id, DbDoc doc)Adds the document to the collection.ResultaddOrReplaceOne(String id, String jsonString)Adds the document to the collection.longcount()Query the number of documents in this collection.ResultcreateIndex(String indexName, DbDoc indexDefinition)Create a new statement defining the creation of an index on this collection.ResultcreateIndex(String indexName, String jsonIndexDefinition)Create a new statement defining the creation of an index on this collection.voiddropIndex(String indexName)Create a new statement defining the removal of an index on this collection.booleanequals(Object other)DatabaseObject.DbObjectStatusexistsInDatabase()Query the existence of this database object.FindStatementfind()Create a new find statement retrieving all documents in the collection.FindStatementfind(String searchCondition)Create a new find statement retrieving documents matching the given search condition.StringgetName()Retrieve the name of the database object represented by the Java object.DbDocgetOne(String id)Return the document with the given id.SchemagetSchema()Retrieve the schema owning this database object.SessiongetSession()Retrieve the session owning the given schema object.inthashCode()ModifyStatementmodify(String searchCondition)Create a new modify statement affecting documents matching the given search condition.DbDocnewDoc()Create a new document.RemoveStatementremove(String searchCondition)Create a new removal statement affecting documents matching the given search condition.ResultremoveOne(String id)Removes the document with the given id.ResultreplaceOne(String id, DbDoc doc)Takes in a document object that will replace the matching document.ResultreplaceOne(String id, String jsonString)Takes in a document object that will replace the matching document.StringtoString()
-
-
-
方法详细资料
-
getSession
public Session getSession()
从接口复制的说明:DatabaseObjectRetrieve the session owning the given schema object.- 指定者:
getSession在接口中DatabaseObject- 返回:
Session
-
getSchema
public Schema getSchema()
从接口复制的说明:DatabaseObjectRetrieve the schema owning this database object.- 指定者:
getSchema在接口中DatabaseObject- 返回:
Schema
-
getName
public String getName()
从接口复制的说明:DatabaseObjectRetrieve the name of the database object represented by the Java object.- 指定者:
getName在接口中DatabaseObject- 返回:
- name
-
existsInDatabase
public DatabaseObject.DbObjectStatus existsInDatabase()
从接口复制的说明:DatabaseObjectQuery the existence of this database object.- 指定者:
existsInDatabase在接口中DatabaseObject- 返回:
DatabaseObject.DbObjectStatus
-
add
public AddStatement add(Map<String,?> doc)
从接口复制的说明:CollectionAdd a document in the form of a Map.- 指定者:
add在接口中Collection- 参数:
doc- map of key-value parameters representing the document fields- 返回:
AddStatement
-
add
public AddStatement add(String... jsonString)
从接口复制的说明:CollectionAdd one or more documents.- 指定者:
add在接口中Collection- 参数:
jsonString- one or more documents given as JSON strings- 返回:
AddStatement
-
add
public AddStatement add(DbDoc doc)
从接口复制的说明:CollectionAdd a document in the form of a DbDoc.- 指定者:
add在接口中Collection- 参数:
doc-DbDoc- 返回:
AddStatement
-
add
public AddStatement add(DbDoc... docs)
从接口复制的说明:CollectionAdd a sequence of documents.- 指定者:
add在接口中Collection- 参数:
docs- one or more documents given asDbDoc- 返回:
AddStatement
-
find
public FindStatement find()
从接口复制的说明:CollectionCreate a new find statement retrieving all documents in the collection.- 指定者:
find在接口中Collection- 返回:
FindStatement
-
find
public FindStatement find(String searchCondition)
从接口复制的说明:CollectionCreate a new find statement retrieving documents matching the given search condition.- 指定者:
find在接口中Collection- 参数:
searchCondition- condition expression- 返回:
FindStatement
-
modify
public ModifyStatement modify(String searchCondition)
从接口复制的说明:CollectionCreate a new modify statement affecting documents matching the given search condition.- 指定者:
modify在接口中Collection- 参数:
searchCondition- condition expression- 返回:
ModifyStatement
-
remove
public RemoveStatement remove(String searchCondition)
从接口复制的说明:CollectionCreate a new removal statement affecting documents matching the given search condition.- 指定者:
remove在接口中Collection- 参数:
searchCondition- condition expression- 返回:
RemoveStatement
-
createIndex
public Result createIndex(String indexName, DbDoc indexDefinition)
从接口复制的说明:CollectionCreate a new statement defining the creation of an index on this collection.Example: collection.createIndex("myIndex", "{\"fields\": [{\"field\": \"$.myGeoJsonField\", \"type\": \"GEOJSON\", \"required\": true, \"options\": 2, \"srid\": 4326}], \"type\":\"SPATIAL\"}");
- 指定者:
createIndex在接口中Collection- 参数:
indexName- index nameindexDefinition- JSON document with the following fields:- fields: array of IndexField objects, each describing a single document member to be included in the index (see below)
- type: string, (optional) the type of index. One of INDEX or SPATIAL (case insensitive). Default is INDEX and may be omitted.
- field: string, the full document path to the document member or field to be indexed
- type: string, one of the supported SQL column types to map the field into (see below for a list). For numeric types, the optional UNSIGNED keyword may follow. For the TEXT type, the length to consider for indexing may be added. Type descriptions are case insensitive.
- required: bool, (optional) true if the field is required to exist in the document. Defaults to false, except for GEOJSON where it defaults to true
- options: int, (optional) special option flags for use when decoding GEOJSON data
- srid: int, (optional) srid value for use when decoding GEOJSON data
- 返回:
Result
-
createIndex
public Result createIndex(String indexName, String jsonIndexDefinition)
从接口复制的说明:CollectionCreate a new statement defining the creation of an index on this collection.Example: collection.createIndex("myIndex", "{\"fields\": [{\"field\": \"$.myGeoJsonField\", \"type\": \"GEOJSON\", \"required\": true, \"options\": 2, \"srid\": 4326}], \"type\":\"SPATIAL\"}");
- 指定者:
createIndex在接口中Collection- 参数:
indexName- index namejsonIndexDefinition- JSON document with the following fields:- fields: array of IndexField objects, each describing a single document member to be included in the index (see below)
- type: string, (optional) the type of index. One of INDEX or SPATIAL. Default is INDEX and may be omitted.
- field: string, the full document path to the document member or field to be indexed
- type: string, one of the supported SQL column types to map the field into (see below for a list). For numeric types, the optional UNSIGNED keyword may follow. For the TEXT type, the length to consider for indexing may be added.
- required: bool, (optional) true if the field is required to exist in the document. Defaults to false, except for GEOJSON where it defaults to true
- options: int, (optional) special option flags for use when decoding GEOJSON data
- srid: int, (optional) srid value for use when decoding GEOJSON data
- 返回:
Result
-
dropIndex
public void dropIndex(String indexName)
从接口复制的说明:CollectionCreate a new statement defining the removal of an index on this collection.- 指定者:
dropIndex在接口中Collection- 参数:
indexName- index name
-
count
public long count()
从接口复制的说明:CollectionQuery the number of documents in this collection.- 指定者:
count在接口中Collection- 返回:
- The number of documents in this collection
-
newDoc
public DbDoc newDoc()
从接口复制的说明:CollectionCreate a new document.- 指定者:
newDoc在接口中Collection- 返回:
DbDoc
-
replaceOne
public Result replaceOne(String id, DbDoc doc)
从接口复制的说明:CollectionTakes in a document object that will replace the matching document. If no matches are found, the function returns normally with no changes being made.- 指定者:
replaceOne在接口中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.- 返回:
- Result object, which will indicate the number of affected documents (1 or 0, if none)
-
replaceOne
public Result replaceOne(String id, String jsonString)
从接口复制的说明:CollectionTakes in a document object that will replace the matching document. If no matches are found, the function returns normally with no changes being made.- 指定者:
replaceOne在接口中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.- 返回:
- Result object, which will indicate the number of affected documents (1 or 0, if none)
-
addOrReplaceOne
public Result addOrReplaceOne(String id, DbDoc doc)
从接口复制的说明:CollectionAdds the document to the collection. The following algorithm applies:- 指定者:
addOrReplaceOne在接口中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.- 返回:
- Result object, which will indicate the number of affected documents (0 - if none, 1 - if added, 2 - if replaced)
-
addOrReplaceOne
public Result addOrReplaceOne(String id, String jsonString)
从接口复制的说明:CollectionAdds the document to the collection. The following algorithm applies:- 指定者:
addOrReplaceOne在接口中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.- 返回:
- Result object, which will indicate the number of affected documents (0 - if none, 1 - if added, 2 - if replaced)
-
getOne
public DbDoc getOne(String id)
从接口复制的说明:CollectionReturn the document with the given id.- 指定者:
getOne在接口中Collection- 参数:
id- the document id of the document to be retrieved- 返回:
- the document, or NULL if no match found
-
removeOne
public Result removeOne(String id)
从接口复制的说明:CollectionRemoves the document with the given id.- 指定者:
removeOne在接口中Collection- 参数:
id- the document id of the document to be removed- 返回:
- Returns a Result object, which will indicate the number of removed documents (1 or 0, if none)
-
-