文档管理中心

您当前正在浏览HarmonyOS开发者3.0版本配套的开发者文档,对应API能力级别为API 8 Release。此版本文档已归档不再维护,推荐您使用HarmonyOS NEXT版本

API参考Java API参考ohos.data.distributed.commonClassSchema

Schema

java.lang.Object

|---ohos.data.distributed.common.Schema

收起
自动换行
深色代码主题
复制
  1. public class Schema
  2. extends Object

Represents the database schema.

You can create Schema objects and put them in Options when creating or opening the database.

Since:

3

Constructor Summary

展开

Constructor

Description

Schema​()

A constructor used to create a Schema instance.

Method Summary

展开

Modifier and Type

Method

Description

List<List<String>>

getCompositeIndexes​()

Obtains the list of composite indexes that has been set for this Schema instance.

List<String>

getIndexes​()

Obtains the list of fields to be indexed in this Schema instance.

FieldNode

getRootFieldNode​()

Obtains the root FieldNode of this Schema instance.

SchemaMode

getSchemaMode​()

Obtains the mode of this Schema instance.

String

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.

展开

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Schema

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

Method Detail

setSchemaMode

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

setIndexes

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

getVersion

public String getVersion​()

Obtains the version number of this Schema instance.

Returns:

Returns the version number of this Schema instance.

Since:

3

getSchemaMode

public SchemaMode getSchemaMode​()

Obtains the mode of this Schema instance.

Returns:

Returns the mode of this Schema instance.

Since:

3

getIndexes

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

getCompositeIndexes

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

setCompositeIndexes

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

getRootFieldNode

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

搜索
请输入您想要搜索的关键词