智能客服
你问我答,随时在线为你解决问题

























您当前正在浏览HarmonyOS开发者3.0版本配套的开发者文档,对应API能力级别为API 8 Release。此版本文档已归档不再维护,推荐您使用HarmonyOS NEXT版本。
| |---ohos.data.distributed.common.Schema 收起 自动换行 深色代码主题 复制 |
Represents the database schema.
You can create Schema objects and put them in Options when creating or opening the database.
Since:
3
Constructor | Description |
|---|---|
Schema() | A constructor used to create a Schema instance. |
Modifier and Type | Method | Description |
|---|---|---|
Obtains the list of composite indexes that has been set for this Schema instance. | ||
getIndexes() | Obtains the list of fields to be indexed in this Schema instance. | |
Obtains the root FieldNode of this Schema instance. | ||
Obtains the mode of this Schema instance. | ||
getVersion() | Obtains the version number of this Schema instance. | |
boolean | setCompositeIndexes(List<List<String>> compositeIndexes) | Sets a list of composite indexes for this Schema instance. |
boolean | setIndexes(List<String> indexes) | Sets the index list of this Schema instance. |
void | setSchemaMode(SchemaMode schemaMode) | Sets the mode of this Schema instance. |
public Schema()
A constructor used to create a Schema instance.
The initialized Schema instance contains an empty index list and a default root FieldNode.
Since:
3
public void setSchemaMode(SchemaMode schemaMode)
Sets the mode of this Schema instance.
Parameters:
Parameter Name | Parameter Description |
|---|---|
schemaMode | Indicates the mode to set for this Schema instance. |
Since:
3
public boolean setIndexes(List<String> indexes)
Sets the index list of this Schema instance.
The index list specifies which fields of the Schema instance are to be indexed.
Each index in the list is a string starting with $..
Parameters:
Parameter Name | Parameter Description |
|---|---|
indexes | Indicates the index list to set. |
Returns:
Returns true if the index list is set successfully; returns false otherwise.
Since:
3
public String getVersion()
Obtains the version number of this Schema instance.
Returns:
Returns the version number of this Schema instance.
Since:
3
public SchemaMode getSchemaMode()
Obtains the mode of this Schema instance.
Returns:
Returns the mode of this Schema instance.
Since:
3
public List<String> getIndexes()
Obtains the list of fields to be indexed in this Schema instance.
Returns:
Returns the list of fields to be indexed.
Since:
3
public List<List<String>> getCompositeIndexes()
Obtains the list of composite indexes that has been set for this Schema instance.
Returns:
Returns the list of composite indexes.
Since:
5
public boolean setCompositeIndexes(List<List<String>> compositeIndexes)
Sets a list of composite indexes for this Schema instance.
A composite index contains multiple index fields of a Schema instance. Each index field in a composite index must be unique. During a query using the composite index, its index fields are used for matching in sequence. The first index field of each composite index cannot be the same as any one of the index fields set via #setIndexes(java.util.List<java.lang.String>) or the first index field of any other composite index.
Parameters:
Parameter Name | Parameter Description |
|---|---|
compositeIndexes | Indicates the composite indexes to set. The value is a list of lists. The inner list indicates a composite index, and the outer list indicates multiple composite indexes. |
Returns:
Returns true if the index list is set successfully; returns false otherwise.
Since:
5
public FieldNode getRootFieldNode()
Obtains the root FieldNode of this Schema instance.
The initialized Schema instance contains a default root FieldNode.
By obtaining the root FieldNode and adding child nodes to it, you can define the Schema instance.
The root FieldNode should contain at least one child node.
Returns:
Returns the root FieldNode of this Schema instance.
Since:
3
智能客服
你问我答,随时在线为你解决问题
合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
解决方案
精准高效的一站式服务支持,助力开发者商业成功