update js commemts

Signed-off-by: smagicyun <yanghongliang.yang@huawei.com>
This commit is contained in:
smagicyun 2021-09-26 16:17:33 +08:00
parent 1988d7fc6e
commit c059cf1d75
3 changed files with 412 additions and 133 deletions

View File

@ -15,28 +15,47 @@
import { AsyncCallback } from './basic'; import { AsyncCallback } from './basic';
import rdb from './@ohos.data.rdb'; import rdb from './@ohos.data.rdb';
/**
* Provides predicates for implementing diverse query methods.
*
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @import import data_dataAbility from '@ohos.data.dataAbility';
* @permission N/A
*/
declare namespace dataAbility { declare namespace dataAbility {
/** /**
* Create an RdbPredicates by table name and DataAbilityPredicates. * Create an RdbPredicates by table name and DataAbilityPredicates.
* *
* @note This method is similar to = of the SQL statement.
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param name Indicates the table name. * @param name Indicates the table name.
* @param dataAbilityPredicates Indicates the dataAbility predicates. * @param dataAbilityPredicates Indicates the dataAbility predicates.
* @return Returns an RdbPredicates. * @return Returns an RdbPredicates.
* @since 7
*/ */
function createRdbPredicates(name: string, dataAbilityPredicates: DataAbilityPredicates): rdb.RdbPredicates; function createRdbPredicates(name: string, dataAbilityPredicates: DataAbilityPredicates): rdb.RdbPredicates;
/** /**
* Manages relational database configurations. * Manages relational database configurations.
* *
* @Syscap SystemCapability.Data.DATA_APPDATAMGR * @since 7
* @version 7 * @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @import import data_dataAbility from '@ohos.data.dataAbility';
* @permission N/A
*/ */
class DataAbilityPredicates { class DataAbilityPredicates {
/** /**
* Configures the DataAbilityPredicates to match the field whose data type is ValueType and value is equal * Configures the DataAbilityPredicates to match the field whose data type is ValueType and value is equal
* to a specified value. * to a specified value.
* *
* @note This method is similar to = of the SQL statement.
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with the DataAbilityPredicates. * @param value Indicates the value to match with the DataAbilityPredicates.
* @return Returns the DataAbilityPredicates that match the specified field. * @return Returns the DataAbilityPredicates that match the specified field.
@ -47,8 +66,10 @@ declare namespace dataAbility {
* Configures the DataAbilityPredicates to match the field whose data type is ValueType and value is unequal to * Configures the DataAbilityPredicates to match the field whose data type is ValueType and value is unequal to
* a specified value. * a specified value.
* *
* This method is similar to != of the SQL statement. * @note This method is similar to != of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with the DataAbilityPredicates. * @param value Indicates the value to match with the DataAbilityPredicates.
* @return Returns the DataAbilityPredicates that match the specified field. * @return Returns the DataAbilityPredicates that match the specified field.
@ -58,9 +79,10 @@ declare namespace dataAbility {
/** /**
* Adds a left parenthesis to the DataAbilityPredicates. * Adds a left parenthesis to the DataAbilityPredicates.
* *
* This method is similar to ( of the SQL statement and needs to be used together * @note This method is similar to ( of the SQL statement and needs to be used together with endWrap().
* with endWrap(). * @since 7
* * @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns the DataAbilityPredicates with the left parenthesis. * @return Returns the DataAbilityPredicates with the left parenthesis.
*/ */
beginWrap(): DataAbilityPredicates; beginWrap(): DataAbilityPredicates;
@ -68,9 +90,11 @@ declare namespace dataAbility {
/** /**
* Adds a right parenthesis to the DataAbilityPredicates. * Adds a right parenthesis to the DataAbilityPredicates.
* *
* This method is similar to ) of the SQL statement and needs to be used together * @note This method is similar to ) of the SQL statement and needs to be used together
* with beginWrap(). * with beginWrap().
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns the DataAbilityPredicates with the right parenthesis. * @return Returns the DataAbilityPredicates with the right parenthesis.
*/ */
endWrap(): DataAbilityPredicates; endWrap(): DataAbilityPredicates;
@ -78,8 +102,10 @@ declare namespace dataAbility {
/** /**
* Adds an or condition to the DataAbilityPredicates. * Adds an or condition to the DataAbilityPredicates.
* *
* This method is similar to or of the SQL statement. * @note This method is similar to or of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns the DataAbilityPredicates with the or condition. * @return Returns the DataAbilityPredicates with the or condition.
*/ */
or(): DataAbilityPredicates; or(): DataAbilityPredicates;
@ -87,8 +113,10 @@ declare namespace dataAbility {
/** /**
* Adds an and condition to the DataAbilityPredicates. * Adds an and condition to the DataAbilityPredicates.
* *
* This method is similar to and of the SQL statement. * @note This method is similar to and of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns the DataAbilityPredicates with the and condition. * @return Returns the DataAbilityPredicates with the and condition.
*/ */
and(): DataAbilityPredicates; and(): DataAbilityPredicates;
@ -97,8 +125,10 @@ declare namespace dataAbility {
* Configures the DataAbilityPredicates to match the field whose data type is string and value * Configures the DataAbilityPredicates to match the field whose data type is string and value
* contains a specified value. * contains a specified value.
* *
* This method is similar to contains of the SQL statement. * @note This method is similar to contains of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with the DataAbilityPredicates. * @param value Indicates the value to match with the DataAbilityPredicates.
* @return Returns the DataAbilityPredicates that match the specified field. * @return Returns the DataAbilityPredicates that match the specified field.
@ -109,8 +139,10 @@ declare namespace dataAbility {
* Configures the DataAbilityPredicates to match the field whose data type is string and value starts * Configures the DataAbilityPredicates to match the field whose data type is string and value starts
* with a specified string. * with a specified string.
* *
* This method is similar to value% of the SQL statement. * @note This method is similar to value% of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with the DataAbilityPredicates. * @param value Indicates the value to match with the DataAbilityPredicates.
* @return Returns the DataAbilityPredicates that match the specified field. * @return Returns the DataAbilityPredicates that match the specified field.
@ -121,8 +153,10 @@ declare namespace dataAbility {
* Configures the DataAbilityPredicates to match the field whose data type is string and value * Configures the DataAbilityPredicates to match the field whose data type is string and value
* ends with a specified string. * ends with a specified string.
* *
* This method is similar to %value of the SQL statement. * @note This method is similar to %value of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with the DataAbilityPredicates. * @param value Indicates the value to match with the DataAbilityPredicates.
* @return Returns the DataAbilityPredicates that match the specified field. * @return Returns the DataAbilityPredicates that match the specified field.
@ -132,8 +166,10 @@ declare namespace dataAbility {
/** /**
* Configures the DataAbilityPredicates to match the fields whose value is null. * Configures the DataAbilityPredicates to match the fields whose value is null.
* *
* This method is similar to is null of the SQL statement. * @note This method is similar to is null of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @return Returns the DataAbilityPredicates that match the specified field. * @return Returns the DataAbilityPredicates that match the specified field.
*/ */
@ -142,8 +178,10 @@ declare namespace dataAbility {
/** /**
* Configures the DataAbilityPredicates to match the specified fields whose value is not null. * Configures the DataAbilityPredicates to match the specified fields whose value is not null.
* *
* This method is similar to is not null of the SQL statement. * @note This method is similar to is not null of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @return Returns the DataAbilityPredicates that match the specified field. * @return Returns the DataAbilityPredicates that match the specified field.
*/ */
@ -153,8 +191,10 @@ declare namespace dataAbility {
* Configures the DataAbilityPredicates to match the fields whose data type is string and value is * Configures the DataAbilityPredicates to match the fields whose data type is string and value is
* similar to a specified string. * similar to a specified string.
* *
* This method is similar to like of the SQL statement. * @note This method is similar to like of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with the DataAbilityPredicates. The percent sign (%) in the value * @param value Indicates the value to match with the DataAbilityPredicates. The percent sign (%) in the value
* is a wildcard (like * in a regular expression). * is a wildcard (like * in a regular expression).
@ -166,18 +206,23 @@ declare namespace dataAbility {
* Configures DataAbilityPredicates to match the specified field whose data type is string and the value contains * Configures DataAbilityPredicates to match the specified field whose data type is string and the value contains
* a wildcard. * a wildcard.
* *
* Different from like, the input parameters of this method are case-sensitive. * @note Different from like, the input parameters of this method are case-sensitive.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with DataAbilityPredicates. * @param value Indicates the value to match with DataAbilityPredicates.
* @return Returns the SQL statement with the specified DataAbilityPredicates. * @return Returns the SQL statement with the specified DataAbilityPredicates.
*
*/ */
glob(field: string, value: string): DataAbilityPredicates; glob(field: string, value: string): DataAbilityPredicates;
/** /**
* Restricts the value of the field to the range between low value and high value. * Restricts the value of the field to the range between low value and high value.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name. * @param field Indicates the column name.
* @param low Indicates the minimum value. * @param low Indicates the minimum value.
* @param high Indicates the maximum value. * @param high Indicates the maximum value.
@ -189,17 +234,24 @@ declare namespace dataAbility {
* Configures DataAbilityPredicates to match the specified field whose data type is int and value is * Configures DataAbilityPredicates to match the specified field whose data type is int and value is
* out of a given range. * out of a given range.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param low Indicates the minimum value to match with DataAbilityPredicates}. * @param low Indicates the minimum value to match with DataAbilityPredicates}.
* @param high Indicates the maximum value to match with DataAbilityPredicates}. * @param high Indicates the maximum value to match with DataAbilityPredicates}.
* @return Returns the SQL query statement with the specified DataAbilityPredicates. * @return Returns the SQL query statement with the specified DataAbilityPredicates.
*
*/ */
notBetween(field: string, low: ValueType, high: ValueType): DataAbilityPredicates; notBetween(field: string, low: ValueType, high: ValueType): DataAbilityPredicates;
/** /**
* Restricts the value of the field to be greater than the specified value. * Restricts the value of the field to be greater than the specified value.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name. * @param field Indicates the column name.
* @param value Indicates the String field. * @param value Indicates the String field.
* @return Returns the SQL query statement with the specified DataAbilityPredicates. * @return Returns the SQL query statement with the specified DataAbilityPredicates.
@ -209,6 +261,10 @@ declare namespace dataAbility {
/** /**
* Restricts the value of the field to be smaller than the specified value. * Restricts the value of the field to be smaller than the specified value.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name. * @param field Indicates the column name.
* @param value Indicates the String field. * @param value Indicates the String field.
* @return Returns the SQL query statement with the specified DataAbilityPredicates. * @return Returns the SQL query statement with the specified DataAbilityPredicates.
@ -218,6 +274,10 @@ declare namespace dataAbility {
/** /**
* Restricts the value of the field to be greater than or equal to the specified value. * Restricts the value of the field to be greater than or equal to the specified value.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name. * @param field Indicates the column name.
* @param value Indicates the String field. * @param value Indicates the String field.
* @return Returns the SQL query statement with the specified DataAbilityPredicates. * @return Returns the SQL query statement with the specified DataAbilityPredicates.
@ -227,6 +287,10 @@ declare namespace dataAbility {
/** /**
* Restricts the value of the field to be smaller than or equal to the specified value. * Restricts the value of the field to be smaller than or equal to the specified value.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name. * @param field Indicates the column name.
* @param value Indicates the String field. * @param value Indicates the String field.
* @return Returns the SQL query statement with the specified DataAbilityPredicates. * @return Returns the SQL query statement with the specified DataAbilityPredicates.
@ -237,6 +301,10 @@ declare namespace dataAbility {
* Restricts the ascending order of the return list. When there are several orders, * Restricts the ascending order of the return list. When there are several orders,
* the one close to the head has the highest priority. * the one close to the head has the highest priority.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name for sorting the return list. * @param field Indicates the column name for sorting the return list.
* @return Returns the SQL query statement with the specified DataAbilityPredicates. * @return Returns the SQL query statement with the specified DataAbilityPredicates.
*/ */
@ -246,6 +314,10 @@ declare namespace dataAbility {
* Restricts the descending order of the return list. When there are several orders, * Restricts the descending order of the return list. When there are several orders,
* the one close to the head has the highest priority. * the one close to the head has the highest priority.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name for sorting the return list. * @param field Indicates the column name for sorting the return list.
* @return Returns the SQL query statement with the specified DataAbilityPredicates. * @return Returns the SQL query statement with the specified DataAbilityPredicates.
*/ */
@ -254,6 +326,10 @@ declare namespace dataAbility {
/** /**
* Restricts each row of the query result to be unique. * Restricts each row of the query result to be unique.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns the SQL query statement with the specified DataAbilityPredicates. * @return Returns the SQL query statement with the specified DataAbilityPredicates.
*/ */
distinct(): DataAbilityPredicates; distinct(): DataAbilityPredicates;
@ -261,6 +337,10 @@ declare namespace dataAbility {
/** /**
* Restricts the max number of return records. * Restricts the max number of return records.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param value Indicates the max length of the return list. * @param value Indicates the max length of the return list.
* @return Returns the SQL query statement with the specified DataAbilityPredicates. * @return Returns the SQL query statement with the specified DataAbilityPredicates.
* @throws IllegalPredicateException Throws this exception if DataAbilityPredicates are added to a wrong position. * @throws IllegalPredicateException Throws this exception if DataAbilityPredicates are added to a wrong position.
@ -270,31 +350,36 @@ declare namespace dataAbility {
/** /**
* Configures DataAbilityPredicates to specify the start position of the returned result. * Configures DataAbilityPredicates to specify the start position of the returned result.
* *
* Use this method together with limit(int). * @note Use this method together with limit(int).
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param rowOffset Indicates the start position of the returned result. The value is a positive integer. * @param rowOffset Indicates the start position of the returned result. The value is a positive integer.
* @return Returns the SQL query statement with the specified AbsPredicates. * @return Returns the SQL query statement with the specified AbsPredicates.
*
*/ */
offsetAs(rowOffset: number): DataAbilityPredicates; offsetAs(rowOffset: number): DataAbilityPredicates;
/** /**
* Configures DataAbilityPredicates to group query results by specified columns. * Configures DataAbilityPredicates to group query results by specified columns.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param fields Indicates the specified columns by which query results are grouped. * @param fields Indicates the specified columns by which query results are grouped.
* @return Returns the DataAbilityPredicates with the specified columns by which query results are grouped. * @return Returns the DataAbilityPredicates with the specified columns by which query results are grouped.
*
*/ */
groupBy(fields: Array<string>): DataAbilityPredicates; groupBy(fields: Array<string>): DataAbilityPredicates;
/** /**
* Configures DataAbilityPredicates to specify the index column. * Configures DataAbilityPredicates to specify the index column.
* *
* Before using this method, you need to create an index column. * @note Before using this method, you need to create an index column.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param indexName Indicates the name of the index column. * @param indexName Indicates the name of the index column.
* @return Returns DataAbilityPredicates with the specified index column. * @return Returns DataAbilityPredicates with the specified index column.
*
*/ */
indexedBy(field: string): DataAbilityPredicates; indexedBy(field: string): DataAbilityPredicates;
@ -302,10 +387,13 @@ declare namespace dataAbility {
* Configures DataAbilityPredicates to match the specified field whose data type is ValueType array and values * Configures DataAbilityPredicates to match the specified field whose data type is ValueType array and values
* are within a given range. * are within a given range.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param values Indicates the values to match with DataAbilityPredicates. * @param values Indicates the values to match with DataAbilityPredicates.
* @return Returns DataAbilityPredicates that matches the specified field. * @return Returns DataAbilityPredicates that matches the specified field.
*
*/ */
in(field: string, value: Array<ValueType>): DataAbilityPredicates; in(field: string, value: Array<ValueType>): DataAbilityPredicates;
@ -313,6 +401,10 @@ declare namespace dataAbility {
* Configures {@code DataAbilityPredicates} to match the specified field whose data type is String array and values * Configures {@code DataAbilityPredicates} to match the specified field whose data type is String array and values
* are out of a given range. * are out of a given range.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param values Indicates the values to match with DataAbilityPredicates. * @param values Indicates the values to match with DataAbilityPredicates.
* @return Returns DataAbilityPredicates that matches the specified field. * @return Returns DataAbilityPredicates that matches the specified field.
@ -321,6 +413,11 @@ declare namespace dataAbility {
} }
/** /**
* Indicates possible value types * Indicates possible value types
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @import import data_rdb from '@ohos.data.rdb';
* @permission N/A
*/ */
type ValueType = number | string | boolean; type ValueType = number | string | boolean;
} }

View File

@ -15,6 +15,15 @@
import { AsyncCallback } from './basic'; import { AsyncCallback } from './basic';
import { ResultSet } from './data/rdb/resultSet'; import { ResultSet } from './data/rdb/resultSet';
/**
* Provides methods for rdbStore create and delete.
*
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @import import data_rdb from '@ohos.data.rdb';
* @permission N/A
*/
declare namespace rdb { declare namespace rdb {
/** /**
* Obtains an RDB store. * Obtains an RDB store.
@ -22,11 +31,14 @@ declare namespace rdb {
* You can set parameters of the RDB store as required. In general, this method is recommended * You can set parameters of the RDB store as required. In general, this method is recommended
* to obtain a rdb store. * to obtain a rdb store.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param config Indicates the configuration of the database related to this RDB store. The configurations include * @param config Indicates the configuration of the database related to this RDB store. The configurations include
* the database path, storage mode, and whether the database is read-only. * the database path, storage mode, and whether the database is read-only.
* @param version Indicates the database version for upgrade or downgrade. * @param version Indicates the database version for upgrade or downgrade.
* @return Returns an RDB store {@link ohos.data.rdb.RdbStore}. * @return Returns an RDB store {@link ohos.data.rdb.RdbStore}.
* @since 7
*/ */
function getRdbStore(config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void; function getRdbStore(config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void;
function getRdbStore(config: StoreConfig, version: number): Promise<RdbStore>; function getRdbStore(config: StoreConfig, version: number): Promise<RdbStore>;
@ -34,9 +46,12 @@ declare namespace rdb {
/** /**
* Deletes the database with a specified name. * Deletes the database with a specified name.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param name Indicates the database name. * @param name Indicates the database name.
* @return Returns true if the database is deleted; returns false otherwise. * @return Returns true if the database is deleted; returns false otherwise.
* @since 7
*/ */
function deleteRdbStore(name: string, callback: AsyncCallback<void>): void; function deleteRdbStore(name: string, callback: AsyncCallback<void>): void;
function deleteRdbStore(name: string): Promise<void>; function deleteRdbStore(name: string): Promise<void>;
@ -46,18 +61,23 @@ declare namespace rdb {
* *
* This class provides methods for creating, querying, updating, and deleting RDBs. * This class provides methods for creating, querying, updating, and deleting RDBs.
* *
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car * @devices phone, tablet, tv, wearable, car
* @Syscap SystemCapability.Data.DATA_APPDATAMGR * @import import data_rdb from '@ohos.data.rdb';
* @version 7 * @permission N/A
*/ */
interface RdbStore { interface RdbStore {
/** /**
* Inserts a row of data into the target table. * Inserts a row of data into the target table.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param name Indicates the target table. * @param name Indicates the target table.
* @param values Indicates the row of data to be inserted into the table. * @param values Indicates the row of data to be inserted into the table.
* @return Returns the row ID if the operation is successful; returns -1 otherwise. * @return Returns the row ID if the operation is successful; returns -1 otherwise.
* @since 7
*/ */
insert(name: string, values: ValuesBucket, callback: AsyncCallback<number>): void; insert(name: string, values: ValuesBucket, callback: AsyncCallback<number>): void;
insert(name: string, values: ValuesBucket): Promise<number>; insert(name: string, values: ValuesBucket): Promise<number>;
@ -65,10 +85,13 @@ declare namespace rdb {
/** /**
* Updates data in the database based on a a specified instance object of rdbPredicates. * Updates data in the database based on a a specified instance object of rdbPredicates.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param values Indicates the row of data to be updated in the database.The key-value pairs are associated with column names of the database table. * @param values Indicates the row of data to be updated in the database.The key-value pairs are associated with column names of the database table.
* @param rdbPredicates Indicates the specified update condition by the instance object of RdbPredicates. * @param rdbPredicates Indicates the specified update condition by the instance object of RdbPredicates.
* @return Returns the number of affected rows. * @return Returns the number of affected rows.
* @since 7
*/ */
update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallback<number>): void; update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallback<number>): void;
update(values: ValuesBucket, rdbPredicates: RdbPredicates): Promise<number>; update(values: ValuesBucket, rdbPredicates: RdbPredicates): Promise<number>;
@ -76,9 +99,12 @@ declare namespace rdb {
/** /**
* Deletes data from the database based on a specified instance object of rdbPredicates. * Deletes data from the database based on a specified instance object of rdbPredicates.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param rdbPredicates Indicates the specified delete condition by the instance object of RdbPredicates. * @param rdbPredicates Indicates the specified delete condition by the instance object of RdbPredicates.
* @return Returns the number of affected rows. * @return Returns the number of affected rows.
* @since 7
*/ */
delete(rdbPredicates: RdbPredicates, callback: AsyncCallback<number>): void; delete(rdbPredicates: RdbPredicates, callback: AsyncCallback<number>): void;
delete(rdbPredicates: RdbPredicates): Promise<number>; delete(rdbPredicates: RdbPredicates): Promise<number>;
@ -86,10 +112,13 @@ declare namespace rdb {
/** /**
* Queries data in the database based on specified conditions. * Queries data in the database based on specified conditions.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param rdbPredicates Indicates the specified query condition by the instance object of RdbPredicates. * @param rdbPredicates Indicates the specified query condition by the instance object of RdbPredicates.
* @param columns Indicates the columns to query. If the value is null, the query applies to all columns. * @param columns Indicates the columns to query. If the value is null, the query applies to all columns.
* @return Returns a ResultSet object if the operation is successful; * @return Returns a ResultSet object if the operation is successful;
* @since 7
*/ */
query(rdbPredicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>): void; query(rdbPredicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>): void;
query(rdbPredicates: RdbPredicates, columns: Array<string>): Promise<ResultSet>; query(rdbPredicates: RdbPredicates, columns: Array<string>): Promise<ResultSet>;
@ -97,9 +126,12 @@ declare namespace rdb {
/** /**
* Executes an SQL statement that contains specified parameters but returns no value. * Executes an SQL statement that contains specified parameters but returns no value.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param sql Indicates the SQL statement to execute. * @param sql Indicates the SQL statement to execute.
* @param bindArgs Indicates the values of the parameters in the SQL statement. The values are strings. * @param bindArgs Indicates the values of the parameters in the SQL statement. The values are strings.
* @since 7
*/ */
executeSql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<void>): void; executeSql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<void>): void;
executeSql(sql: string, bindArgs: Array<ValueType>): Promise<void>; executeSql(sql: string, bindArgs: Array<ValueType>): Promise<void>;
@ -107,11 +139,23 @@ declare namespace rdb {
/** /**
* Indicates possible value types * Indicates possible value types
*
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @import import data_rdb from '@ohos.data.rdb';
* @permission N/A
*/ */
type ValueType = number | string | boolean; type ValueType = number | string | boolean;
/** /**
* Values in buckets are stored in key-value pairs * Values in buckets are stored in key-value pairs
*
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @import import data_rdb from '@ohos.data.rdb';
* @permission N/A
*/ */
type ValuesBucket = { type ValuesBucket = {
[key: string]: ValueType | Uint8Array | null; [key: string]: ValueType | Uint8Array | null;
@ -120,13 +164,18 @@ declare namespace rdb {
/** /**
* Manages relational database configurations. * Manages relational database configurations.
* *
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car * @devices phone, tablet, tv, wearable, car
* @Syscap SystemCapability.Data.DATA_APPDATAMGR * @import import data_rdb from '@ohos.data.rdb';
* @version 7 * @permission N/A
*/ */
interface StoreConfig { interface StoreConfig {
/** /**
* Indicates the name of the database file * Indicates the name of the database file
*
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
*/ */
name: string; name: string;
} }
@ -134,14 +183,21 @@ declare namespace rdb {
/** /**
* Manages relational database configurations. * Manages relational database configurations.
* *
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car * @devices phone, tablet, tv, wearable, car
* @Syscap SystemCapability.Data.DATA_APPDATAMGR * @import import data_rdb from '@ohos.data.rdb';
* @version 7 * @permission N/A
*/ */
class RdbPredicates { class RdbPredicates {
/** /**
* A parameterized constructor used to create an RdbPredicates instance. * A parameterized constructor used to create an RdbPredicates instance.
* name Indicates the table name of the database. * name Indicates the table name of the database.
*
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
*/ */
constructor(name: string) constructor(name: string)
@ -149,6 +205,10 @@ declare namespace rdb {
* Configures the RdbPredicates to match the field whose data type is ValueType and value is equal * Configures the RdbPredicates to match the field whose data type is ValueType and value is equal
* to a specified value. * to a specified value.
* *
* @note This method is similar to = of the SQL statement.
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with the RdbPredicates. * @param value Indicates the value to match with the RdbPredicates.
* @return Returns the RdbPredicates that match the specified field. * @return Returns the RdbPredicates that match the specified field.
@ -159,8 +219,10 @@ declare namespace rdb {
* Configures the RdbPredicates to match the field whose data type is ValueType and value is unequal to * Configures the RdbPredicates to match the field whose data type is ValueType and value is unequal to
* a specified value. * a specified value.
* *
* This method is similar to != of the SQL statement. * @note This method is similar to != of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with the RdbPredicates. * @param value Indicates the value to match with the RdbPredicates.
* @return Returns the RdbPredicates that match the specified field. * @return Returns the RdbPredicates that match the specified field.
@ -170,9 +232,10 @@ declare namespace rdb {
/** /**
* Adds a left parenthesis to the RdbPredicates. * Adds a left parenthesis to the RdbPredicates.
* *
* This method is similar to ( of the SQL statement and needs to be used together * @note This method is similar to ( of the SQL statement and needs to be used together with endWrap().
* with endWrap(). * @since 7
* * @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns the RdbPredicates with the left parenthesis. * @return Returns the RdbPredicates with the left parenthesis.
*/ */
beginWrap(): RdbPredicates; beginWrap(): RdbPredicates;
@ -180,9 +243,11 @@ declare namespace rdb {
/** /**
* Adds a right parenthesis to the RdbPredicates. * Adds a right parenthesis to the RdbPredicates.
* *
* This method is similar to ) of the SQL statement and needs to be used together * @note This method is similar to ) of the SQL statement and needs to be used together
* with beginWrap(). * with beginWrap().
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns the RdbPredicates with the right parenthesis. * @return Returns the RdbPredicates with the right parenthesis.
*/ */
endWrap(): RdbPredicates; endWrap(): RdbPredicates;
@ -190,8 +255,10 @@ declare namespace rdb {
/** /**
* Adds an or condition to the RdbPredicates. * Adds an or condition to the RdbPredicates.
* *
* This method is similar to or of the SQL statement. * @note This method is similar to or of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns the RdbPredicates with the or condition. * @return Returns the RdbPredicates with the or condition.
*/ */
or(): RdbPredicates; or(): RdbPredicates;
@ -199,8 +266,10 @@ declare namespace rdb {
/** /**
* Adds an and condition to the RdbPredicates. * Adds an and condition to the RdbPredicates.
* *
* This method is similar to and of the SQL statement. * @note This method is similar to and of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns the RdbPredicates with the and condition. * @return Returns the RdbPredicates with the and condition.
*/ */
and(): RdbPredicates; and(): RdbPredicates;
@ -209,8 +278,10 @@ declare namespace rdb {
* Configures the RdbPredicates to match the field whose data type is string and value * Configures the RdbPredicates to match the field whose data type is string and value
* contains a specified value. * contains a specified value.
* *
* This method is similar to contains of the SQL statement. * @note This method is similar to contains of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with the RdbPredicates. * @param value Indicates the value to match with the RdbPredicates.
* @return Returns the RdbPredicates that match the specified field. * @return Returns the RdbPredicates that match the specified field.
@ -221,8 +292,10 @@ declare namespace rdb {
* Configures the RdbPredicates to match the field whose data type is string and value starts * Configures the RdbPredicates to match the field whose data type is string and value starts
* with a specified string. * with a specified string.
* *
* This method is similar to value% of the SQL statement. * @note This method is similar to value% of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with the RdbPredicates. * @param value Indicates the value to match with the RdbPredicates.
* @return Returns the RdbPredicates that match the specified field. * @return Returns the RdbPredicates that match the specified field.
@ -233,8 +306,10 @@ declare namespace rdb {
* Configures the RdbPredicates to match the field whose data type is string and value * Configures the RdbPredicates to match the field whose data type is string and value
* ends with a specified string. * ends with a specified string.
* *
* This method is similar to %value of the SQL statement. * @note This method is similar to %value of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with the RdbPredicates. * @param value Indicates the value to match with the RdbPredicates.
* @return Returns the RdbPredicates that match the specified field. * @return Returns the RdbPredicates that match the specified field.
@ -244,8 +319,10 @@ declare namespace rdb {
/** /**
* Configures the RdbPredicates to match the fields whose value is null. * Configures the RdbPredicates to match the fields whose value is null.
* *
* This method is similar to is null of the SQL statement. * @note This method is similar to is null of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @return Returns the RdbPredicates that match the specified field. * @return Returns the RdbPredicates that match the specified field.
*/ */
@ -254,8 +331,10 @@ declare namespace rdb {
/** /**
* Configures the RdbPredicates to match the specified fields whose value is not null. * Configures the RdbPredicates to match the specified fields whose value is not null.
* *
* This method is similar to is not null of the SQL statement. * @note This method is similar to is not null of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @return Returns the RdbPredicates that match the specified field. * @return Returns the RdbPredicates that match the specified field.
*/ */
@ -265,8 +344,10 @@ declare namespace rdb {
* Configures the RdbPredicates to match the fields whose data type is string and value is * Configures the RdbPredicates to match the fields whose data type is string and value is
* similar to a specified string. * similar to a specified string.
* *
* This method is similar to like of the SQL statement. * @note This method is similar to like of the SQL statement.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with the RdbPredicates. The percent sign (%) in the value * @param value Indicates the value to match with the RdbPredicates. The percent sign (%) in the value
* is a wildcard (like * in a regular expression). * is a wildcard (like * in a regular expression).
@ -278,18 +359,23 @@ declare namespace rdb {
* Configures RdbPredicates to match the specified field whose data type is string and the value contains * Configures RdbPredicates to match the specified field whose data type is string and the value contains
* a wildcard. * a wildcard.
* *
* Different from like, the input parameters of this method are case-sensitive. * @note Different from like, the input parameters of this method are case-sensitive.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param value Indicates the value to match with RdbPredicates. * @param value Indicates the value to match with RdbPredicates.
* @return Returns the SQL statement with the specified RdbPredicates. * @return Returns the SQL statement with the specified RdbPredicates.
*
*/ */
glob(field: string, value: string): RdbPredicates; glob(field: string, value: string): RdbPredicates;
/** /**
* Restricts the value of the field to the range between low value and high value. * Restricts the value of the field to the range between low value and high value.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name. * @param field Indicates the column name.
* @param low Indicates the minimum value. * @param low Indicates the minimum value.
* @param high Indicates the maximum value. * @param high Indicates the maximum value.
@ -301,17 +387,24 @@ declare namespace rdb {
* Configures RdbPredicates to match the specified field whose data type is int and value is * Configures RdbPredicates to match the specified field whose data type is int and value is
* out of a given range. * out of a given range.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param low Indicates the minimum value to match with DataAbilityPredicates}. * @param low Indicates the minimum value to match with DataAbilityPredicates.
* @param high Indicates the maximum value to match with DataAbilityPredicates}. * @param high Indicates the maximum value to match with DataAbilityPredicates.
* @return Returns the SQL query statement with the specified RdbPredicates. * @return Returns the SQL query statement with the specified RdbPredicates.
*
*/ */
notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates; notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates;
/** /**
* Restricts the value of the field to be greater than the specified value. * Restricts the value of the field to be greater than the specified value.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name. * @param field Indicates the column name.
* @param value Indicates the String field. * @param value Indicates the String field.
* @return Returns the SQL query statement with the specified RdbPredicates. * @return Returns the SQL query statement with the specified RdbPredicates.
@ -321,6 +414,10 @@ declare namespace rdb {
/** /**
* Restricts the value of the field to be smaller than the specified value. * Restricts the value of the field to be smaller than the specified value.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name. * @param field Indicates the column name.
* @param value Indicates the String field. * @param value Indicates the String field.
* @return Returns the SQL query statement with the specified RdbPredicates. * @return Returns the SQL query statement with the specified RdbPredicates.
@ -330,6 +427,10 @@ declare namespace rdb {
/** /**
* Restricts the value of the field to be greater than or equal to the specified value. * Restricts the value of the field to be greater than or equal to the specified value.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name. * @param field Indicates the column name.
* @param value Indicates the String field. * @param value Indicates the String field.
* @return Returns the SQL query statement with the specified RdbPredicates. * @return Returns the SQL query statement with the specified RdbPredicates.
@ -339,6 +440,10 @@ declare namespace rdb {
/** /**
* Restricts the value of the field to be smaller than or equal to the specified value. * Restricts the value of the field to be smaller than or equal to the specified value.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name. * @param field Indicates the column name.
* @param value Indicates the String field. * @param value Indicates the String field.
* @return Returns the SQL query statement with the specified RdbPredicates. * @return Returns the SQL query statement with the specified RdbPredicates.
@ -349,6 +454,10 @@ declare namespace rdb {
* Restricts the ascending order of the return list. When there are several orders, * Restricts the ascending order of the return list. When there are several orders,
* the one close to the head has the highest priority. * the one close to the head has the highest priority.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name for sorting the return list. * @param field Indicates the column name for sorting the return list.
* @return Returns the SQL query statement with the specified RdbPredicates. * @return Returns the SQL query statement with the specified RdbPredicates.
*/ */
@ -358,6 +467,10 @@ declare namespace rdb {
* Restricts the descending order of the return list. When there are several orders, * Restricts the descending order of the return list. When there are several orders,
* the one close to the head has the highest priority. * the one close to the head has the highest priority.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name for sorting the return list. * @param field Indicates the column name for sorting the return list.
* @return Returns the SQL query statement with the specified RdbPredicates. * @return Returns the SQL query statement with the specified RdbPredicates.
*/ */
@ -366,6 +479,10 @@ declare namespace rdb {
/** /**
* Restricts each row of the query result to be unique. * Restricts each row of the query result to be unique.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns the SQL query statement with the specified RdbPredicates. * @return Returns the SQL query statement with the specified RdbPredicates.
*/ */
distinct(): RdbPredicates; distinct(): RdbPredicates;
@ -373,40 +490,48 @@ declare namespace rdb {
/** /**
* Restricts the max number of return records. * Restricts the max number of return records.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param value Indicates the max length of the return list. * @param value Indicates the max length of the return list.
* @return Returns the SQL query statement with the specified RdbPredicates. * @return Returns the SQL query statement with the specified RdbPredicates.
* @throws IllegalPredicateException Throws this exception if RdbPredicates are added to a wrong position.
*/ */
limitAs(value: number): RdbPredicates; limitAs(value: number): RdbPredicates;
/** /**
* Configures RdbPredicates to specify the start position of the returned result. * Configures RdbPredicates to specify the start position of the returned result.
* *
* Use this method together with limit(int). * @note Use this method together with limit(int).
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param rowOffset Indicates the start position of the returned result. The value is a positive integer. * @param rowOffset Indicates the start position of the returned result. The value is a positive integer.
* @return Returns the SQL query statement with the specified AbsPredicates. * @return Returns the SQL query statement with the specified AbsPredicates.
*
*/ */
offsetAs(rowOffset: number): RdbPredicates; offsetAs(rowOffset: number): RdbPredicates;
/** /**
* Configures RdbPredicates to group query results by specified columns. * Configures RdbPredicates to group query results by specified columns.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param fields Indicates the specified columns by which query results are grouped. * @param fields Indicates the specified columns by which query results are grouped.
* @return Returns the RdbPredicates with the specified columns by which query results are grouped. * @return Returns the RdbPredicates with the specified columns by which query results are grouped.
*
*/ */
groupBy(fields: Array<string>): RdbPredicates; groupBy(fields: Array<string>): RdbPredicates;
/** /**
* Configures RdbPredicates to specify the index column. * Configures RdbPredicates to specify the index column.
* *
* Before using this method, you need to create an index column. * @note Before using this method, you need to create an index column.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param indexName Indicates the name of the index column. * @param indexName Indicates the name of the index column.
* @return Returns RdbPredicates with the specified index column. * @return Returns RdbPredicates with the specified index column.
*
*/ */
indexedBy(field: string): RdbPredicates; indexedBy(field: string): RdbPredicates;
@ -414,10 +539,13 @@ declare namespace rdb {
* Configures RdbPredicates to match the specified field whose data type is ValueType array and values * Configures RdbPredicates to match the specified field whose data type is ValueType array and values
* are within a given range. * are within a given range.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param values Indicates the values to match with RdbPredicates. * @param values Indicates the values to match with RdbPredicates.
* @return Returns RdbPredicates that matches the specified field. * @return Returns RdbPredicates that matches the specified field.
*
*/ */
in(field: string, value: Array<ValueType>): RdbPredicates; in(field: string, value: Array<ValueType>): RdbPredicates;
@ -425,6 +553,10 @@ declare namespace rdb {
* Configures RdbPredicates to match the specified field whose data type is ValueType array and values * Configures RdbPredicates to match the specified field whose data type is ValueType array and values
* are out of a given range. * are out of a given range.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param field Indicates the column name in the database table. * @param field Indicates the column name in the database table.
* @param values Indicates the values to match with RdbPredicates. * @param values Indicates the values to match with RdbPredicates.
* @return Returns RdbPredicates that matches the specified field. * @return Returns RdbPredicates that matches the specified field.

View File

@ -17,66 +17,82 @@ import { AsyncCallback } from '../../basic'
/** /**
* Provides methods for accessing a database result set generated by querying the database. * Provides methods for accessing a database result set generated by querying the database.
* *
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car * @devices phone, tablet, tv, wearable, car
* @Syscap SystemCapability.Data.DATA_APPDATAMGR * @import import data_rdb from '@ohos.data.rdb';
* @version 7 * @permission N/A
*/ */
interface ResultSet { interface ResultSet {
/** /**
* Obtains the names of all columns in a result set. * Obtains the names of all columns in a result set.
* *
* The column names are returned as a string array, in which the strings are in the same order * @note The column names are returned as a string array, in which the strings are in the same order
* as the columns in the result set. * as the columns in the result set.
*
* @since 7 * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
*/ */
columnNames: Array<string>; columnNames: Array<string>;
/** /**
* Obtains the number of columns in the result set. * Obtains the number of columns in the result set.
* *
* The returned number is equal to the length of the string array returned by the * @note The returned number is equal to the length of the string array returned by the
* columnCount method. * columnCount method.
*
* @since 7 * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
*/ */
columnCount: number; columnCount: number;
/** /**
* Obtains the number of rows in the result set. * Obtains the number of rows in the result set.
* *
* @note N/A
* @since 7 * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
*/ */
rowCount: number; rowCount: number;
/** /**
* Obtains the current index of the result set. * Obtains the current index of the result set.
* *
* The result set index starts from 0. * @note The result set index starts from 0.
*
* @since 7 * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
*/ */
rowIndex: number; rowIndex: number;
/** /**
* Checks whether the result set is positioned at the first row. * Checks whether the result set is positioned at the first row.
* *
* @note N/A
* @since 7 * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
*/ */
isAtFirstRow: boolean; isAtFirstRow: boolean;
/** /**
* Checks whether the result set is positioned at the last row. * Checks whether the result set is positioned at the last row.
* *
* @note N/A
* @since 7 * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
*/ */
isAtLastRow: boolean; isAtLastRow: boolean;
/** /**
* Checks whether the result set is positioned after the last row. * Checks whether the result set is positioned after the last row.
* *
* @note N/A
* @since 7 * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
*/ */
isEnded: boolean; isEnded: boolean;
@ -84,7 +100,10 @@ interface ResultSet {
* Returns whether the cursor is pointing to the position before the first * Returns whether the cursor is pointing to the position before the first
* row. * row.
* *
* @note N/A
* @since 7 * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
*/ */
isStarted: boolean; isStarted: boolean;
@ -93,29 +112,34 @@ interface ResultSet {
* *
* If the result set is closed by calling the close method, true will be returned. * If the result set is closed by calling the close method, true will be returned.
* *
* @note N/A
* @since 7 * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
*/ */
isClosed: boolean; isClosed: boolean;
/** /**
* Obtains the column index based on the specified column name. * Obtains the column index based on the specified column name.
* *
* The column name is passed as an input parameter. * @note The column name is passed as an input parameter.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param columnName Indicates the name of the specified column in the result set. * @param columnName Indicates the name of the specified column in the result set.
* @return Returns the index of the specified column. * @return Returns the index of the specified column.
* @since 7
*/ */
getColumnIndex(columnName: string): number; getColumnIndex(columnName: string): number;
/** /**
* Obtains the column name based on the specified column index. * Obtains the column name based on the specified column index.
* *
* The column index is passed as an input parameter. * @note The column index is passed as an input parameter.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param columnIndex Indicates the index of the specified column in the result set. * @param columnIndex Indicates the index of the specified column in the result set.
* @return Returns the name of the specified column. * @return Returns the name of the specified column.
* @since 7
*/ */
getColumnName(columnIndex: number): string; getColumnName(columnIndex: number): string;
@ -123,123 +147,149 @@ interface ResultSet {
* Go to the specified row of the result set forwards or backwards by an offset relative to its current position. * Go to the specified row of the result set forwards or backwards by an offset relative to its current position.
* A positive offset indicates moving backwards, and a negative offset indicates moving forwards. * A positive offset indicates moving backwards, and a negative offset indicates moving forwards.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param offset Indicates the offset relative to the current position. * @param offset Indicates the offset relative to the current position.
* @return Returns true if the result set is moved successfully and does not go beyond the range; * @return Returns true if the result set is moved successfully and does not go beyond the range;
* returns false otherwise. * returns false otherwise.
* @since 7
*/ */
goTo(offset: number): boolean; goTo(offset: number): boolean;
/** /**
* Go to the specified row of the result set. * Go to the specified row of the result set.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param rowIndex Indicates the index of the specified row, which starts from 0. * @param rowIndex Indicates the index of the specified row, which starts from 0.
* @return Returns true if the result set is moved successfully; returns false otherwise. * @return Returns true if the result set is moved successfully; returns false otherwise.
* @since 7
*/ */
goToRow(position: number): boolean; goToRow(position: number): boolean;
/** /**
* Go to the first row of the result set. * Go to the first row of the result set.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns true if the result set is moved successfully; * @return Returns true if the result set is moved successfully;
* returns false otherwise, for example, if the result set is empty. * returns false otherwise, for example, if the result set is empty.
* @since 7
*/ */
goToFirstRow(): boolean; goToFirstRow(): boolean;
/** /**
* Go to the last row of the result set. * Go to the last row of the result set.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns true if the result set is moved successfully; * @return Returns true if the result set is moved successfully;
* returns false otherwise, for example, if the result set is empty. * returns false otherwise, for example, if the result set is empty.
* @since 7
*/ */
goToLastRow(): boolean; goToLastRow(): boolean;
/** /**
* Go to the next row of the result set. * Go to the next row of the result set.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns true if the result set is moved successfully; * @return Returns true if the result set is moved successfully;
* returns false otherwise, for example, if the result set is already in the last row. * returns false otherwise, for example, if the result set is already in the last row.
* @since 7
*/ */
goToNextRow(): boolean; goToNextRow(): boolean;
/** /**
* Go to the previous row of the result set. * Go to the previous row of the result set.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns true if the result set is moved successfully; * @return Returns true if the result set is moved successfully;
* returns false otherwise, for example, if the result set is already in the first row. * returns false otherwise, for example, if the result set is already in the first row.
* @since 7
*/ */
goToPreviousRow(): boolean; goToPreviousRow(): boolean;
/** /**
* Obtains the value of the specified column in the current row as a byte array. * Obtains the value of the specified column in the current row as a byte array.
* *
* The implementation class determines whether to throw an exception if the value of the specified column * @note The implementation class determines whether to throw an exception if the value of the specified column
* in the current row is null or the specified column is not of the Blob type. * in the current row is null or the specified column is not of the Blob type.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param columnIndex Indicates the specified column index, which starts from 0. * @param columnIndex Indicates the specified column index, which starts from 0.
* @return Returns the value of the specified column as a byte array. * @return Returns the value of the specified column as a byte array.
* @since 7
*/ */
getBlob(columnIndex: number): Uint8Array; getBlob(columnIndex: number): Uint8Array;
/** /**
* Obtains the value of the specified column in the current row as string. * Obtains the value of the specified column in the current row as string.
* *
* The implementation class determines whether to throw an exception if the value of the specified column * @note The implementation class determines whether to throw an exception if the value of the specified column
* in the current row is null or the specified column is not of the string type. * in the current row is null or the specified column is not of the string type.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param columnIndex Indicates the specified column index, which starts from 0. * @param columnIndex Indicates the specified column index, which starts from 0.
* @return Returns the value of the specified column as a string. * @return Returns the value of the specified column as a string.
* @since 7
*/ */
getString(columnIndex: number): string; getString(columnIndex: number): string;
/** /**
* Obtains the value of the specified column in the current row as long. * Obtains the value of the specified column in the current row as long.
* *
* The implementation class determines whether to throw an exception if the value of the specified column * @note The implementation class determines whether to throw an exception if the value of the specified column
* in the current row is null, the specified column is not of the integer type * in the current row is null, the specified column is not of the integer type.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param columnIndex Indicates the specified column index, which starts from 0. * @param columnIndex Indicates the specified column index, which starts from 0.
* @return Returns the value of the specified column as a long. * @return Returns the value of the specified column as a long.
* @since 7
*/ */
getLong(columnIndex: number): number; getLong(columnIndex: number): number;
/** /**
* Obtains the value of the specified column in the current row as double. * Obtains the value of the specified column in the current row as double.
* *
* The implementation class determines whether to throw an exception if the value of the specified column * @note The implementation class determines whether to throw an exception if the value of the specified column
* in the current row is null, the specified column is not of the double type * in the current row is null, the specified column is not of the double type.
* * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param columnIndex Indicates the specified column index, which starts from 0. * @param columnIndex Indicates the specified column index, which starts from 0.
* @return Returns the value of the specified column as a double. * @return Returns the value of the specified column as a double.
* @since 7
*/ */
getDouble(columnIndex: number): number; getDouble(columnIndex: number): number;
/** /**
* Checks whether the value of the specified column in the current row is null. * Checks whether the value of the specified column in the current row is null.
* *
* @note N/A
* @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @param columnIndex Indicates the specified column index, which starts from 0. * @param columnIndex Indicates the specified column index, which starts from 0.
* @return Returns true if the value of the specified column in the current row is null; * @return Returns true if the value of the specified column in the current row is null;
* returns false otherwise. * returns false otherwise.
* @since 7
*/ */
isColumnNull(columnIndex: number): boolean; isColumnNull(columnIndex: number): boolean;
/** /**
* Closes the result set. * Closes the result set.
* *
* Calling this method on the result set will release all of its resources and makes it ineffective. * @note Calling this method on the result set will release all of its resources and makes it ineffective.
*
* @return Returns true if the result set is closed; returns false otherwise.
* @since 7 * @since 7
* @sysCap SystemCapability.Data.DATA_APPDATAMGR
* @devices phone, tablet, tv, wearable, car
* @return Returns true if the result set is closed; returns false otherwise.
*/ */
close(): void; close(): void;
} }