From f4617d9bd388647e3ff1aeae1f1e84bf1b544e64 Mon Sep 17 00:00:00 2001 From: duanweiling Date: Sat, 7 May 2022 11:17:39 +0800 Subject: [PATCH 1/7] =?UTF-8?q?js=20API=20=E6=8E=A5=E5=8F=A3=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- ...application.DataShareExtensionAbility.d.ts | 19 +- api/@ohos.data.DataSharePredicates.d.ts | 443 ++++++++++++++++++ api/@ohos.data.DataShareResultSet.d.ts | 370 +++++++++++++++ api/@ohos.data.DataShareValuesBucket.d.ts | 34 ++ api/@ohos.data.dataShare.d.ts | 32 +- 5 files changed, 873 insertions(+), 25 deletions(-) create mode 100644 api/@ohos.data.DataSharePredicates.d.ts create mode 100644 api/@ohos.data.DataShareResultSet.d.ts create mode 100644 api/@ohos.data.DataShareValuesBucket.d.ts diff --git a/api/@ohos.application.DataShareExtensionAbility.d.ts b/api/@ohos.application.DataShareExtensionAbility.d.ts index 4293b42d04..04841a35a7 100644 --- a/api/@ohos.application.DataShareExtensionAbility.d.ts +++ b/api/@ohos.application.DataShareExtensionAbility.d.ts @@ -14,11 +14,11 @@ */ import { AsyncCallback } from "./basic"; -import { ResultSet } from './data/rdb/resultSet'; import ExtensionContext from "./application/ExtensionContext"; import Want from './@ohos.application.Want'; -import dataAbility from './@ohos.data.dataAbility'; -import rdb from './@ohos.data.rdb'; +import DataShareResultSet from './@ohos.data.DataShareResultSet'; +import DataSharePredicates from './@ohos.data.DataSharePredicates'; +import { DataShareValuesBucket } from './@ohos.data.DataShareValuesBucket'; /** * class of datashare extension ability. @@ -95,7 +95,7 @@ export default class DataShareExtensionAbility { * @return Returns the index of the newly inserted data record. * @StageModelOnly */ - insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback): void; + insert?(uri: string, valueBucket: DataShareValuesBucket, callback: AsyncCallback): void; /** * Updates one or more data records in the database. This method should be implemented by a data share. @@ -110,7 +110,7 @@ export default class DataShareExtensionAbility { * @return Returns the number of data records updated. * @StageModelOnly */ - update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, + update?(uri: string, valueBucket: DataShareValuesBucket, predicates: DataSharePredicates, callback: AsyncCallback): void; /** @@ -125,7 +125,7 @@ export default class DataShareExtensionAbility { * @return Returns the number of data records deleted. * @StageModelOnly */ - delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; + delete?(uri: string, predicates: DataSharePredicates, callback: AsyncCallback): void; /** * Queries one or more data records in the database. This method should be implemented by a data share. @@ -141,8 +141,8 @@ export default class DataShareExtensionAbility { * @return Returns the queried data. * @StageModelOnly */ - query?(uri: string, columns: Array, predicates: dataAbility.DataAbilityPredicates, - callback: AsyncCallback): void; + query?(uri: string, columns: Array, predicates: DataSharePredicates, + callback: AsyncCallback): void; /** * Obtains the MIME type matching the data specified by the URI of the data share. This method should be @@ -170,7 +170,8 @@ export default class DataShareExtensionAbility { * @return Returns the number of data records inserted. * @StageModelOnly */ - batchInsert?(uri: string, valueBuckets: Array, callback: AsyncCallback): void; + batchInsert?(uri: string, valueBuckets: Array, + callback: AsyncCallback): void; /** * Converts the given {@code uri} that refer to the data share into a normalized URI. A normalized URI can be diff --git a/api/@ohos.data.DataSharePredicates.d.ts b/api/@ohos.data.DataSharePredicates.d.ts new file mode 100644 index 0000000000..674759e23c --- /dev/null +++ b/api/@ohos.data.DataSharePredicates.d.ts @@ -0,0 +1,443 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Manages relational database configurations. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import import data_dataShare from '@ohos.data.dataShare'; + * @permission N/A + */ +export default class DataSharePredicates { + /** + * Configures the DataSharePredicates to match the field whose data type is ValueType and value is equal + * to a specified value. + * + * @note This method is similar to = of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. + * @return Returns the DataSharePredicates that match the specified field. + */ + equalTo(field: string, value: ValueType): DataSharePredicates; + + /** + * Configures the DataSharePredicates to match the field whose data type is ValueType and value is unequal to + * a specified value. + * + * @note This method is similar to != of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. + * @return Returns the DataSharePredicates that match the specified field. + */ + notEqualTo(field: string, value: ValueType): DataSharePredicates; + + /** + * Adds a left parenthesis to the DataSharePredicates. + * + * @note This method is similar to ( of the SQL statement and needs to be used together with endWrap(). + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the DataSharePredicates with the left parenthesis. + */ + beginWrap(): DataSharePredicates; + + /** + * Adds a right parenthesis to the DataSharePredicates. + * + * @note This method is similar to ) of the SQL statement and needs to be used together + * with beginWrap(). + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the DataSharePredicates with the right parenthesis. + */ + endWrap(): DataSharePredicates; + + /** + * Adds an or condition to the DataSharePredicates. + * + * @note This method is similar to or of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the DataSharePredicates with the or condition. + */ + or(): DataSharePredicates; + + /** + * Adds an and condition to the DataSharePredicates. + * + * @note This method is similar to and of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the DataSharePredicates with the and condition. + */ + and(): DataSharePredicates; + /** + * Configures the DataSharePredicates to match the field whose data type is string and value + * contains a specified value. + * + * @note This method is similar to contains of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. + * @return Returns the DataSharePredicates that match the specified field. + */ + contains(field: string, value: string): DataSharePredicates; + + /** + * Configures the DataSharePredicates to match the field whose data type is string and value starts + * with a specified string. + * + * @note This method is similar to value% of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. + * @return Returns the DataSharePredicates that match the specified field. + */ + beginsWith(field: string, value: string): DataSharePredicates; + + /** + * Configures the DataSharePredicates to match the field whose data type is string and value + * ends with a specified string. + * + * @note This method is similar to %value of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. + * @return Returns the DataSharePredicates that match the specified field. + */ + endsWith(field: string, value: string): DataSharePredicates; + + /** + * Configures the DataSharePredicates to match the fields whose value is null. + * + * @note This method is similar to is null of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @return Returns the DataSharePredicates that match the specified field. + */ + isNull(field: string): DataSharePredicates; + + /** + * Configures the DataSharePredicates to match the specified fields whose value is not null. + * + * @note This method is similar to is not null of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @return Returns the DataSharePredicates that match the specified field. + */ + isNotNull(field: string): DataSharePredicates; + + /** + * Configures the DataSharePredicates to match the fields whose data type is string and value is + * similar to a specified string. + * + * @note This method is similar to like of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. The percent sign (%) in the value + * is a wildcard (like * in a regular expression). + * @return Returns the DataSharePredicates that match the specified field. + */ + like(field: string, value: string): DataSharePredicates; + + /** + * Configures the DataSharePredicates to match the fields whose data type is string and value is + * similar to a specified string. + * + * @note This method is similar to unlike of the SQL statement. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with the DataSharePredicates. The percent sign (%) in the value + * is a wildcard (like * in a regular expression). + * @return Returns the DataSharePredicates that match the specified field. + */ + unlike(field: string, value: string): DataSharePredicates; + + /** + * Configures DataSharePredicates to match the specified field whose data type is string and the value contains + * a wildcard. + * + * @note Different from like, the input parameters of this method are case-sensitive. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param value Indicates the value to match with DataSharePredicates. + * @return Returns the SQL statement with the specified DataSharePredicates. + */ + glob(field: string, value: string): DataSharePredicates; + + /** + * Restricts the value of the field to the range between low value and high value. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param low Indicates the minimum value. + * @param high Indicates the maximum value. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + between(field: string, low: ValueType, high: ValueType): DataSharePredicates; + + /** + * Configures DataSharePredicates to match the specified field whose data type is int and value is + * out of a given range. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param low Indicates the minimum value to match with DataSharePredicates}. + * @param high Indicates the maximum value to match with DataSharePredicates}. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates; + + /** + * Restricts the value of the field to be greater than the specified value. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + greaterThan(field: string, value: ValueType): DataSharePredicates; + + /** + * Restricts the value of the field to be smaller than the specified value. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + lessThan(field: string, value: ValueType): DataSharePredicates; + + /** + * Restricts the value of the field to be greater than or equal to the specified value. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + greaterThanOrEqualTo(field: string, value: ValueType): DataSharePredicates; + + /** + * Restricts the value of the field to be smaller than or equal to the specified value. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name. + * @param value Indicates the String field. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + lessThanOrEqualTo(field: string, value: ValueType): DataSharePredicates; + + /** + * Restricts the ascending order of the return list. When there are several orders, + * the one close to the head has the highest priority. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name for sorting the return list. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + orderByAsc(field: string): DataSharePredicates; + + /** + * Restricts the descending order of the return list. When there are several orders, + * the one close to the head has the highest priority. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name for sorting the return list. + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + orderByDesc(field: string): DataSharePredicates; + + /** + * Restricts each row of the query result to be unique. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the SQL query statement with the specified DataSharePredicates. + */ + distinct(): DataSharePredicates; + + /** + * Construct a query object to specify the number of results and the starting position. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param total Represents the specified number of results. + * @param offset Indicates the starting position. + * @return Returns the query object. + */ + limit(total: number, offset: number): DataSharePredicates; + + /** + * Configures DataSharePredicates to specify the start position of the returned result. + * + * @note Use this method together with limit(int). + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @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. + */ + offsetAs(rowOffset: number): DataSharePredicates; + + /** + * Configures DataSharePredicates to group query results by specified columns. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param fields Indicates the specified columns by which query results are grouped. + * @return Returns the DataSharePredicates with the specified columns by which query results are grouped. + */ + groupBy(fields: Array): DataSharePredicates; + + /** + * Configures DataSharePredicates to specify the index column. + * + * @note Before using this method, you need to create an index column. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param indexName Indicates the name of the index column. + * @return Returns DataSharePredicates with the specified index column. + */ + indexedBy(field: string): DataSharePredicates; + + /** + * Configures DataSharePredicates to match the specified field whose data type is ValueType array and values + * are within a given range. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param values Indicates the values to match with DataSharePredicates. + * @return Returns DataSharePredicates that matches the specified field. + */ + in(field: string, value: Array): DataSharePredicates; + + /** + * Configures {@code DataSharePredicates} to match the specified field whose data type is String array and values + * are out of a given range. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param field Indicates the column name in the database table. + * @param values Indicates the values to match with DataSharePredicates. + * @return Returns DataSharePredicates that matches the specified field. + */ + notIn(field: string, value: Array): DataSharePredicates; + + /** + * Configures {@code DataSharePredicates} Creates a query condition using the specified key prefix. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param prefix Represents the specified key prefix. + * @return Returns the query object. + */ + prefixKey(prefix: string): DataSharePredicates; + + /** + * Configures {@code DataSharePredicates} Sets a specified index + * that will be preferentially used for DataSharePredicates. + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param index Indicates the index to set. + * @return Returns the query object. + */ + setSuggestIndex(index: string): DataSharePredicates; + + /** + * Configures {@code DataSharePredicates} Specify all remote devices which connect to local device + * when syncing distributed database. + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns DataSharePredicates that matches the specified field. + */ + inAllDevices(): DataSharePredicates; + + /** + * Configures {@code DataSharePredicates} Specify remote devices when syncing distributed database. + * when syncing distributed database. + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param devices The remote device ID within the specified network. + * @return Returns the predicate that matches the specified field. + */ + inDevices(devices: Array): DataSharePredicates; + + /** + * Configures {@code DataSharePredicates} Public query reset. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns the reset query object. + */ + reset(): DataSharePredicates; + + /** + * Configures {@code DataSharePredicates} Set a table name. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param name Table name. + * @return Returns the query object. + */ + setTableName(name:string): DataSharePredicates; +} +/** + * Indicates possible value types + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @permission N/A + */ +type ValueType = number | string | boolean; diff --git a/api/@ohos.data.DataShareResultSet.d.ts b/api/@ohos.data.DataShareResultSet.d.ts new file mode 100644 index 0000000000..3fff8c96f7 --- /dev/null +++ b/api/@ohos.data.DataShareResultSet.d.ts @@ -0,0 +1,370 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Indicates the {@code DataType}. + * + *

{@code DataType} is obtained based on the value. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import N/A + */ +export enum DataType { + /** + * Indicates that the data type is null. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import N/A + */ + TYPE_NULL = 0, + + /** + * Indicates that the data type is long. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import N/A + */ + TYPE_LONG = 1, + + /** + * Indicates that the data type is double. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import N/A + */ + TYPE_DOUBLE = 2, + + /** + * Indicates that the data type is byte string. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import N/A + * */ + TYPE_STRING = 3, + + /** + * Indicates that the data type is blob. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import N/A + * */ + TYPE_BLOB = 4 +} + +/** + * Provides methods for accessing a datashare abstract result set generated by querying the database. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + export interface DataShareAbstractResultSet { + /** + * Obtains the names of all columns in a abstract result set. + * + * @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. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + columnNames: Array; + + /** + * Obtains the number of rows in the abstract result set. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + rowCount: number; +} + +/** + * Provides methods for accessing a datashare result set generated by querying the database. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ +export default interface DataShareResultSet { + /** + * Obtains the names of all columns or keys in a result set. + * + * @note The column or key names are returned as a string array, in which the strings are in the same order + * as the columns or keys in the result set. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + columnOrKeyNames: Array; + + /** + * Obtains the number of columns or keys in the result set. + * + * @note The returned number is equal to the length of the string array returned by the + * columnOrKeyCount method. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + columnOrKeyCount: number; + + /** + * Obtains the number of rows in the result set. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + rowCount: number; + + /** + * Obtains the current index of the result set. + * + * @note The result set index starts from 0. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + rowIndex: number; + + /** + * Checks whether the result set is positioned at the first row. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + isAtFirstRow: boolean; + + /** + * Checks whether the result set is positioned at the last row. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + isAtLastRow: boolean; + + /** + * Checks whether the result set is positioned after the last row. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + isEnded: boolean; + + /** + * Returns whether the cursor is pointing to the position before the first + * row. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + isStarted: boolean; + + /** + * Checks whether the current result set is closed. + * + * If the result set is closed by calling the close method, true will be returned. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + */ + isClosed: boolean; + + /** + * Go to the first row of the result set. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is empty. + */ + goToFirstRow(): boolean; + + /** + * Go to the last row of the result set. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is empty. + */ + goToLastRow(): boolean; + + /** + * Go to the next row of the result set. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @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. + */ + goToNextRow(): boolean; + + /** + * Go to the previous row of the result set. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @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. + */ + goToPreviousRow(): boolean; + + /** + * 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. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @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; + * returns false otherwise. + */ + goTo(offset: number): boolean; + + /** + * Go to the specified row of the result set. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @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. + */ + goToRow(position: number): boolean; + + /** + * Obtains the value of the specified column or key in the current row as a byte array. + * + * @note The implementation class determines whether to throw an exception if the value of the specified + * column or key in the current row is null or the specified column or key is not of the Blob type. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. + * @return Returns the value of the specified column or key as a byte array. + */ + getBlob(columnOrKeyIndex: number): Uint8Array; + + /** + * Obtains the value of the specified column or key in the current row as string. + * + * @note The implementation class determines whether to throw an exception if the value of the specified + * column or key in the current row is null or the specified column or key is not of the string type. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. + * @return Returns the value of the specified column or key as a string. + */ + getString(columnOrKeyIndex: number): string; + + /** + * Obtains the value of the specified column or key in the current row as long. + * + * @note The implementation class determines whether to throw an exception if the value of the specified + * column or key in the current row is null, the specified column or key is not of the integer type. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. + * @return Returns the value of the specified column or key as a int. + */ + getInt(columnOrKeyIndex: number): number; + + /** + * Obtains the value of the specified column or key in the current row as long. + * + * @note The implementation class determines whether to throw an exception if the value of the specified + * column or key in the current row is null, the specified column or key is not of the integer type. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. + * @return Returns the value of the specified column or key as a long. + */ + getLong(columnOrKeyIndex: number): number; + + /** + * Obtains the value of the specified column or key in the current row as double. + * + * @note The implementation class determines whether to throw an exception if the value of the specified + * column or key in the current row is null, the specified column or key is not of the double type. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. + * @return Returns the value of the specified column or key as a double. + */ + getDouble(columnOrKeyIndex: number): number; + + /** + * Checks whether the value of the specified column or key in the current row is null. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. + * @return Returns true if the value of the specified column or key in the current row is null; + * returns false otherwise. + */ + isColumnOrKeyNull(columnOrKeyIndex: number): boolean; + + /** + * Closes the result set. + * + * @note Calling this method on the result set will release all of its resources and makes it ineffective. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @return Returns true if the result set is closed; returns false otherwise. + */ + close(): void; + + /** + * Obtains the column index or key index based on the specified column name or key name. + * + * @note The column name or key name is passed as an input parameter. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnOrKeyName Indicates the name of the specified column or key in the result set. + * @return Returns the index of the specified column or key. + */ + getColumnOrKeyIndex(columnOrKeyName: string): number; + + /** + * Obtains the column name or key name based on the specified column index or key index. + * + * @note The column index or key index is passed as an input parameter. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnOrKeyIndex Indicates the index of the specified column or key in the result set. + * @return Returns the name of the specified column or key. + */ + getColumnOrKeyName(columnOrKeyIndex: number): string; + + /** + * Obtains the dataType of the specified column or key. + * + * @note The implementation class determines whether to throw an exception if the value of the specified + * column or key in the current row is null, the specified column or key is not in the data type. + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. + * @return Returns the dataType of the specified column or key. + */ + getDataType(columnOrKeyIndex: number): DataType; +} \ No newline at end of file diff --git a/api/@ohos.data.DataShareValuesBucket.d.ts b/api/@ohos.data.DataShareValuesBucket.d.ts new file mode 100644 index 0000000000..4ed509b54a --- /dev/null +++ b/api/@ohos.data.DataShareValuesBucket.d.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Indicates possible value types + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import N/A + */ +export type ValueType = number | string | boolean; + +/** + * Values in buckets are stored in key-value pairs + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import N/A + */ +export type DataShareValuesBucket = { + [key: string]: ValueType | Uint8Array | null; +} \ No newline at end of file diff --git a/api/@ohos.data.dataShare.d.ts b/api/@ohos.data.dataShare.d.ts index 7637fb041c..3705a95331 100644 --- a/api/@ohos.data.dataShare.d.ts +++ b/api/@ohos.data.dataShare.d.ts @@ -14,11 +14,11 @@ */ import { AsyncCallback } from './basic'; -import Want from './@ohos.application.want'; -import { ResultSet } from './data/rdb/resultSet'; +import { Want } from './ability/want'; import Context from './application/Context'; -import dataAbility from './@ohos.data.dataAbility'; -import rdb from './@ohos.data.rdb'; +import DataShareResultSet from './@ohos.data.DataShareResultSet'; +import DataSharePredicates from './@ohos.data.DataSharePredicates'; +import { DataShareValuesBucket } from './@ohos.data.DataShareValuesBucket'; declare namespace dataShare { /** @@ -88,8 +88,8 @@ declare namespace dataShare { * @return Returns the index of the inserted data record. * @StageModelOnly */ - insert(uri: string, value: rdb.ValuesBucket, callback: AsyncCallback): void; - insert(uri: string, value: rdb.ValuesBucket): Promise; + insert(uri: string, value: DataShareValuesBucket, callback: AsyncCallback): void; + insert(uri: string, value: DataShareValuesBucket): Promise; /** * Deletes one or more data records from the database. @@ -100,8 +100,8 @@ declare namespace dataShare { * @return Returns the number of data records deleted. * @StageModelOnly */ - delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; - delete(uri: string, predicates: dataAbility.DataAbilityPredicates): Promise; + delete(uri: string, predicates: DataSharePredicates, callback: AsyncCallback): void; + delete(uri: string, predicates: DataSharePredicates): Promise; /** @@ -114,8 +114,8 @@ declare namespace dataShare { * @return Returns the query result. * @StageModelOnly */ - query(uri: string, columns: Array, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; - query(uri: string, columns: Array, predicates: dataAbility.DataAbilityPredicates): Promise; + query(uri: string, columns: Array, predicates: DataSharePredicates, callback: AsyncCallback): void; + query(uri: string, columns: Array, predicates: DataSharePredicates): Promise; /** * Updates data records in the database. @@ -127,8 +127,8 @@ declare namespace dataShare { * @return Returns the number of data records updated. * @StageModelOnly */ - update(uri: string, value: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; - update(uri: string, value: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates): Promise; + update(uri: string, value: DataShareValuesBucket, predicates: DataSharePredicates, callback: AsyncCallback): void; + update(uri: string, value: DataShareValuesBucket, predicates: DataSharePredicates): Promise; /** @@ -140,8 +140,8 @@ declare namespace dataShare { * @return Returns the number of data records inserted. * @StageModelOnly */ - batchInsert(uri: string, values: Array, callback: AsyncCallback): void; - batchInsert(uri: string, values: Array): Promise; + batchInsert(uri: string, values: Array, callback: AsyncCallback): void; + batchInsert(uri: string, values: Array): Promise; /** * Obtains the MIME type of the date specified by the given uri. @@ -170,7 +170,7 @@ declare namespace dataShare { getFileTypes(uri: string, mimeTypeFilter: string): Promise>; /** - * Converts the given {@code uri} that refers to the Data ability into a normalized {@link ohos.utils.net.Uri}. + * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}. * A normalized uri can be used across devices, persisted, backed up, and restored. *

To transfer a normalized uri from another environment to the current environment, you should call this * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)} @@ -178,7 +178,7 @@ declare namespace dataShare { * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @param uri Indicates the {@link ohos.utils.net.Uri} object to normalize. - * @return Returns the normalized {@code Uri} object if the Data ability supports uri normalization; + * @return Returns the normalized {@code Uri} object if the DataShare supports uri normalization; * returns {@code null} otherwise. * @throws DataShareRemoteException Throws this exception if the remote process exits. * @throws NullPointerException Throws this exception if {@code uri} is null. -- Gitee From 5e8f29c21a776973db1a01cb8c3f50e09220b62f Mon Sep 17 00:00:00 2001 From: duanweiling Date: Sat, 7 May 2022 16:01:31 +0800 Subject: [PATCH 2/7] =?UTF-8?q?js=20API=20=E6=8E=A5=E5=8F=A3=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- api/@ohos.application.DataShareExtensionAbility.d.ts | 4 ++-- api/@ohos.data.DataSharePredicates.d.ts | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/api/@ohos.application.DataShareExtensionAbility.d.ts b/api/@ohos.application.DataShareExtensionAbility.d.ts index 04841a35a7..d826670979 100644 --- a/api/@ohos.application.DataShareExtensionAbility.d.ts +++ b/api/@ohos.application.DataShareExtensionAbility.d.ts @@ -16,7 +16,7 @@ import { AsyncCallback } from "./basic"; import ExtensionContext from "./application/ExtensionContext"; import Want from './@ohos.application.Want'; -import DataShareResultSet from './@ohos.data.DataShareResultSet'; +import { DataShareAbstractResultSet } from './@ohos.data.DataShareResultSet'; import DataSharePredicates from './@ohos.data.DataSharePredicates'; import { DataShareValuesBucket } from './@ohos.data.DataShareValuesBucket'; @@ -142,7 +142,7 @@ export default class DataShareExtensionAbility { * @StageModelOnly */ query?(uri: string, columns: Array, predicates: DataSharePredicates, - callback: AsyncCallback): void; + callback: AsyncCallback): void; /** * Obtains the MIME type matching the data specified by the URI of the data share. This method should be diff --git a/api/@ohos.data.DataSharePredicates.d.ts b/api/@ohos.data.DataSharePredicates.d.ts index 674759e23c..2ea4c96556 100644 --- a/api/@ohos.data.DataSharePredicates.d.ts +++ b/api/@ohos.data.DataSharePredicates.d.ts @@ -13,6 +13,8 @@ * limitations under the License. */ +import { ValueType } from './@ohos.data.DataShareValuesBucket'; + /** * Manages relational database configurations. * @@ -434,10 +436,3 @@ export default class DataSharePredicates { */ setTableName(name:string): DataSharePredicates; } -/** - * Indicates possible value types - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @permission N/A - */ -type ValueType = number | string | boolean; -- Gitee From 2b111f3cb8d93d944416c2854c2d41c84707a6a5 Mon Sep 17 00:00:00 2001 From: duanweiling Date: Wed, 11 May 2022 10:28:46 +0800 Subject: [PATCH 3/7] =?UTF-8?q?JS=20API=20=E6=8E=A5=E5=8F=A3=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BF=AE=E6=94=B90511?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- api/@ohos.data.DataSharePredicates.d.ts | 17 +++-------------- api/@ohos.data.dataShare.d.ts | 4 ++-- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/api/@ohos.data.DataSharePredicates.d.ts b/api/@ohos.data.DataSharePredicates.d.ts index 2ea4c96556..3a68dbdc7f 100644 --- a/api/@ohos.data.DataSharePredicates.d.ts +++ b/api/@ohos.data.DataSharePredicates.d.ts @@ -213,8 +213,8 @@ export default class DataSharePredicates { * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core * @param field Indicates the column name in the database table. - * @param low Indicates the minimum value to match with DataSharePredicates}. - * @param high Indicates the maximum value to match with DataSharePredicates}. + * @param low Indicates the minimum value to match with DataSharePredicates. + * @param high Indicates the maximum value to match with DataSharePredicates. * @return Returns the SQL query statement with the specified DataSharePredicates. */ notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates; @@ -341,7 +341,7 @@ export default class DataSharePredicates { * @note Before using this method, you need to create an index column. * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param indexName Indicates the name of the index column. + * @param field Indicates the name of the index column. * @return Returns DataSharePredicates with the specified index column. */ indexedBy(field: string): DataSharePredicates; @@ -424,15 +424,4 @@ export default class DataSharePredicates { * @return Returns the reset query object. */ reset(): DataSharePredicates; - - /** - * Configures {@code DataSharePredicates} Set a table name. - * - * @note N/A - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param name Table name. - * @return Returns the query object. - */ - setTableName(name:string): DataSharePredicates; } diff --git a/api/@ohos.data.dataShare.d.ts b/api/@ohos.data.dataShare.d.ts index 3705a95331..e6c3f0c01d 100644 --- a/api/@ohos.data.dataShare.d.ts +++ b/api/@ohos.data.dataShare.d.ts @@ -114,8 +114,8 @@ declare namespace dataShare { * @return Returns the query result. * @StageModelOnly */ - query(uri: string, columns: Array, predicates: DataSharePredicates, callback: AsyncCallback): void; - query(uri: string, columns: Array, predicates: DataSharePredicates): Promise; + query(uri: string, predicates: DataSharePredicates, columns: Array, callback: AsyncCallback): void; + query(uri: string, predicates: DataSharePredicates, columns: Array): Promise; /** * Updates data records in the database. -- Gitee From 2d729d9ca4ff24fa9eca269e9f98059d9bf187ed Mon Sep 17 00:00:00 2001 From: duanweiling Date: Wed, 11 May 2022 19:14:07 +0800 Subject: [PATCH 4/7] =?UTF-8?q?JS=20API=20=E6=8E=A5=E5=8F=A3=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- ...application.DataShareExtensionAbility.d.ts | 109 +++++++------- api/@ohos.data.DataSharePredicates.d.ts | 58 ++------ api/@ohos.data.DataShareResultSet.d.ts | 136 +++--------------- api/@ohos.data.ValuesBucket.d.ts | 34 +++++ api/@ohos.data.dataShare.d.ts | 22 +-- 5 files changed, 126 insertions(+), 233 deletions(-) create mode 100644 api/@ohos.data.ValuesBucket.d.ts diff --git a/api/@ohos.application.DataShareExtensionAbility.d.ts b/api/@ohos.application.DataShareExtensionAbility.d.ts index d826670979..25fb04f053 100644 --- a/api/@ohos.application.DataShareExtensionAbility.d.ts +++ b/api/@ohos.application.DataShareExtensionAbility.d.ts @@ -16,9 +16,8 @@ import { AsyncCallback } from "./basic"; import ExtensionContext from "./application/ExtensionContext"; import Want from './@ohos.application.Want'; -import { DataShareAbstractResultSet } from './@ohos.data.DataShareResultSet'; import DataSharePredicates from './@ohos.data.DataSharePredicates'; -import { DataShareValuesBucket } from './@ohos.data.DataShareValuesBucket'; +import { ValuesBucket } from './@ohos.data.ValuesBucket'; /** * class of datashare extension ability. @@ -29,22 +28,6 @@ import { DataShareValuesBucket } from './@ohos.data.DataShareValuesBucket'; * @StageModelOnly */ export default class DataShareExtensionAbility { - /** - * Opens a file in a specified remote path. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Provider - * @param uri Indicates the path of the file to open. - * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access - * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing - * file, "wa" for write-only access to append to any existing data, "rw" for read and write access on - * any existing data, or "rwt" for read and write access that truncates any existing file. - * @param callback Indicates the callback when openfile success - * @return Returns the file descriptor. - * @StageModelOnly - */ - openFile(uri: string, mode: string, callback: AsyncCallback): void; - openFile(uri: string, mode: string): Promise; /** * Indicates datashare extension ability context. * @@ -68,21 +51,21 @@ export default class DataShareExtensionAbility { onCreate?(want: Want): void; /** - * Obtains the MIME type of files. This method should be implemented by a data share. + * Opens a file in a specified remote path. * * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider - * @param uri Indicates the path of the files to obtain. - * @param mimeTypeFilter Indicates the MIME type of the files to obtain. This parameter cannot be set to {@code - * null}. - *

1. "*/*": Obtains all types supported by a data share. - *

2. "image/*": Obtains files whose main type is image of any subtype. - *

3. "*/jpg": Obtains files whose subtype is JPG of any main type. - * @systemapi Hide this for inner system use. - * @return Returns the MIME type of the matched files; returns null if there is no type that matches the Data + * @param uri Indicates the path of the file to open. + * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access + * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing + * file, "wa" for write-only access to append to any existing data, "rw" for read and write access on + * any existing data, or "rwt" for read and write access that truncates any existing file. + * @param callback Indicates the callback when openfile success + * @return Returns the file descriptor. * @StageModelOnly */ - getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void; + openFile(uri: string, mode: string, callback: AsyncCallback): void; + openFile(uri: string, mode: string): Promise; /** * Inserts a data record into the database. This method should be implemented by a data share. @@ -95,23 +78,7 @@ export default class DataShareExtensionAbility { * @return Returns the index of the newly inserted data record. * @StageModelOnly */ - insert?(uri: string, valueBucket: DataShareValuesBucket, callback: AsyncCallback): void; - - /** - * Updates one or more data records in the database. This method should be implemented by a data share. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Provider - * @param uri Indicates the database table storing the data to update. - * @param valueBucket Indicates the data to update. This parameter can be null. - * @param predicates Indicates filter criteria. If this parameter is null, all data records will be updated by - * default. - * @systemapi Hide this for inner system use. - * @return Returns the number of data records updated. - * @StageModelOnly - */ - update?(uri: string, valueBucket: DataShareValuesBucket, predicates: DataSharePredicates, - callback: AsyncCallback): void; + insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback): void; /** * Deletes one or more data records. This method should be implemented by a data share. @@ -133,16 +100,45 @@ export default class DataShareExtensionAbility { * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider * @param uri Indicates the database table storing the data to query. - * @param columns Indicates the columns to be queried, in array, for example, {"name","age"}. You should define - * the processing logic when this parameter is null. * @param predicates Indicates filter criteria. If this parameter is null, all data records will be queried by * default. + * @param columns Indicates the columns to be queried, in array, for example, {"name","age"}. You should define + * the processing logic when this parameter is null. * @systemapi Hide this for inner system use. * @return Returns the queried data. * @StageModelOnly */ - query?(uri: string, columns: Array, predicates: DataSharePredicates, - callback: AsyncCallback): void; + query?(uri: string, predicates: DataSharePredicates, columns: Array, callback: AsyncCallback): void; + + /** + * Updates one or more data records in the database. This method should be implemented by a data share. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @param uri Indicates the database table storing the data to update. + * @param valueBucket Indicates the data to update. This parameter can be null. + * @param predicates Indicates filter criteria. If this parameter is null, all data records will be updated by + * default. + * @systemapi Hide this for inner system use. + * @return Returns the number of data records updated. + * @StageModelOnly + */ + update?(uri: string, valueBucket: ValuesBucket, predicates: DataSharePredicates, + callback: AsyncCallback): void; + + /** + * Inserts multiple data records into the database. This method should be implemented by a data share. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @param uri Indicates the position where the data is to insert. + * @param valueBuckets Indicates the data to insert. + * @systemapi Hide this for inner system use. + * @return Returns the number of data records inserted. + * @StageModelOnly + */ + batchInsert?(uri: string, valueBuckets: Array, + callback: AsyncCallback): void; /** * Obtains the MIME type matching the data specified by the URI of the data share. This method should be @@ -160,18 +156,21 @@ export default class DataShareExtensionAbility { getType?(uri: string, callback: AsyncCallback): void; /** - * Inserts multiple data records into the database. This method should be implemented by a data share. + * Obtains the MIME type of files. This method should be implemented by a data share. * * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider - * @param uri Indicates the position where the data is to insert. - * @param valueBuckets Indicates the data to insert. + * @param uri Indicates the path of the files to obtain. + * @param mimeTypeFilter Indicates the MIME type of the files to obtain. This parameter cannot be set to {@code + * null}. + *

1. "*/*": Obtains all types supported by a data share. + *

2. "image/*": Obtains files whose main type is image of any subtype. + *

3. "*/jpg": Obtains files whose subtype is JPG of any main type. * @systemapi Hide this for inner system use. - * @return Returns the number of data records inserted. + * @return Returns the MIME type of the matched files; returns null if there is no type that matches the Data * @StageModelOnly */ - batchInsert?(uri: string, valueBuckets: Array, - callback: AsyncCallback): void; + getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void; /** * Converts the given {@code uri} that refer to the data share into a normalized URI. A normalized URI can be diff --git a/api/@ohos.data.DataSharePredicates.d.ts b/api/@ohos.data.DataSharePredicates.d.ts index 3a68dbdc7f..1122bc0d68 100644 --- a/api/@ohos.data.DataSharePredicates.d.ts +++ b/api/@ohos.data.DataSharePredicates.d.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { ValueType } from './@ohos.data.DataShareValuesBucket'; +import { ValueType } from './@ohos.data.ValuesBucket'; /** * Manages relational database configurations. @@ -314,18 +314,7 @@ export default class DataSharePredicates { limit(total: number, offset: number): DataSharePredicates; /** - * Configures DataSharePredicates to specify the start position of the returned result. - * - * @note Use this method together with limit(int). - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @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. - */ - offsetAs(rowOffset: number): DataSharePredicates; - - /** - * Configures DataSharePredicates to group query results by specified columns. + * Configures {@code DataSharePredicates} to group query results by specified columns. * * @note N/A * @since 9 @@ -336,7 +325,7 @@ export default class DataSharePredicates { groupBy(fields: Array): DataSharePredicates; /** - * Configures DataSharePredicates to specify the index column. + * Configures {@code DataSharePredicates} to specify the index column. * * @note Before using this method, you need to create an index column. * @since 9 @@ -347,7 +336,7 @@ export default class DataSharePredicates { indexedBy(field: string): DataSharePredicates; /** - * Configures DataSharePredicates to match the specified field whose data type is ValueType array and values + * Configures {@code DataSharePredicates} to match the specified field whose data type is ValueType array and values * are within a given range. * * @note N/A @@ -384,44 +373,13 @@ export default class DataSharePredicates { prefixKey(prefix: string): DataSharePredicates; /** - * Configures {@code DataSharePredicates} Sets a specified index - * that will be preferentially used for DataSharePredicates. - * @note N/A - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param index Indicates the index to set. - * @return Returns the query object. - */ - setSuggestIndex(index: string): DataSharePredicates; - - /** - * Configures {@code DataSharePredicates} Specify all remote devices which connect to local device - * when syncing distributed database. - * @note N/A - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @return Returns DataSharePredicates that matches the specified field. - */ - inAllDevices(): DataSharePredicates; - - /** - * Configures {@code DataSharePredicates} Specify remote devices when syncing distributed database. - * when syncing distributed database. - * @note N/A - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param devices The remote device ID within the specified network. - * @return Returns the predicate that matches the specified field. - */ - inDevices(devices: Array): DataSharePredicates; - - /** - * Configures {@code DataSharePredicates} Public query reset. + * Configures {@code DataSharePredicates} to match the specified value whose key is within a given range. * * @note N/A * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @return Returns the reset query object. + * @param keys Represents the key names. + * @return Returns the query object. */ - reset(): DataSharePredicates; + inKeys(keys: Array): DataSharePredicates; } diff --git a/api/@ohos.data.DataShareResultSet.d.ts b/api/@ohos.data.DataShareResultSet.d.ts index 3fff8c96f7..b451cc427b 100644 --- a/api/@ohos.data.DataShareResultSet.d.ts +++ b/api/@ohos.data.DataShareResultSet.d.ts @@ -64,33 +64,6 @@ export enum DataType { TYPE_BLOB = 4 } -/** - * Provides methods for accessing a datashare abstract result set generated by querying the database. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - */ - export interface DataShareAbstractResultSet { - /** - * Obtains the names of all columns in a abstract result set. - * - * @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. - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - */ - columnNames: Array; - - /** - * Obtains the number of rows in the abstract result set. - * - * @note N/A - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - */ - rowCount: number; -} - /** * Provides methods for accessing a datashare result set generated by querying the database. * @@ -106,17 +79,16 @@ export default interface DataShareResultSet { * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core */ - columnOrKeyNames: Array; + columnNames: Array; /** * Obtains the number of columns or keys in the result set. * - * @note The returned number is equal to the length of the string array returned by the - * columnOrKeyCount method. + * @note The returned number is equal to the length of the string array returned by the columnCount method. * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core */ - columnOrKeyCount: number; + columnCount: number; /** * Obtains the number of rows in the result set. @@ -127,52 +99,6 @@ export default interface DataShareResultSet { */ rowCount: number; - /** - * Obtains the current index of the result set. - * - * @note The result set index starts from 0. - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - */ - rowIndex: number; - - /** - * Checks whether the result set is positioned at the first row. - * - * @note N/A - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - */ - isAtFirstRow: boolean; - - /** - * Checks whether the result set is positioned at the last row. - * - * @note N/A - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - */ - isAtLastRow: boolean; - - /** - * Checks whether the result set is positioned after the last row. - * - * @note N/A - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - */ - isEnded: boolean; - - /** - * Returns whether the cursor is pointing to the position before the first - * row. - * - * @note N/A - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - */ - isStarted: boolean; - /** * Checks whether the current result set is closed. * @@ -247,7 +173,7 @@ export default interface DataShareResultSet { * @note N/A * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param rowIndex Indicates the index of the specified row, which starts from 0. + * @param position Indicates the index of the specified row, which starts from 1. * @return Returns true if the result set is moved successfully; returns false otherwise. */ goToRow(position: number): boolean; @@ -259,10 +185,10 @@ export default interface DataShareResultSet { * column or key in the current row is null or the specified column or key is not of the Blob type. * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. + * @param columnIndex Indicates the specified column index or key index, which starts from 0. * @return Returns the value of the specified column or key as a byte array. */ - getBlob(columnOrKeyIndex: number): Uint8Array; + getBlob(columnIndex: number): Uint8Array; /** * Obtains the value of the specified column or key in the current row as string. @@ -271,34 +197,22 @@ export default interface DataShareResultSet { * column or key in the current row is null or the specified column or key is not of the string type. * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. + * @param columnIndex Indicates the specified column index or key index, which starts from 0. * @return Returns the value of the specified column or key as a string. */ - getString(columnOrKeyIndex: number): string; + getString(columnIndex: number): string; /** * Obtains the value of the specified column or key in the current row as long. * * @note The implementation class determines whether to throw an exception if the value of the specified - * column or key in the current row is null, the specified column or key is not of the integer type. + * column or key in the current row is null, the specified column or key is not of the long type. * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. - * @return Returns the value of the specified column or key as a int. - */ - getInt(columnOrKeyIndex: number): number; - - /** - * Obtains the value of the specified column or key in the current row as long. - * - * @note The implementation class determines whether to throw an exception if the value of the specified - * column or key in the current row is null, the specified column or key is not of the integer type. - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. + * @param columnIndex Indicates the specified column index or key index, which starts from 0. * @return Returns the value of the specified column or key as a long. */ - getLong(columnOrKeyIndex: number): number; + getLong(columnIndex: number): number; /** * Obtains the value of the specified column or key in the current row as double. @@ -307,22 +221,10 @@ export default interface DataShareResultSet { * column or key in the current row is null, the specified column or key is not of the double type. * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. + * @param columnIndex Indicates the specified column index or key index, which starts from 0. * @return Returns the value of the specified column or key as a double. */ - getDouble(columnOrKeyIndex: number): number; - - /** - * Checks whether the value of the specified column or key in the current row is null. - * - * @note N/A - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. - * @return Returns true if the value of the specified column or key in the current row is null; - * returns false otherwise. - */ - isColumnOrKeyNull(columnOrKeyIndex: number): boolean; + getDouble(columnIndex: number): number; /** * Closes the result set. @@ -340,10 +242,10 @@ export default interface DataShareResultSet { * @note The column name or key name is passed as an input parameter. * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param columnOrKeyName Indicates the name of the specified column or key in the result set. + * @param columnName Indicates the name of the specified column or key in the result set. * @return Returns the index of the specified column or key. */ - getColumnOrKeyIndex(columnOrKeyName: string): number; + getColumnIndex(columnName: string): number; /** * Obtains the column name or key name based on the specified column index or key index. @@ -351,10 +253,10 @@ export default interface DataShareResultSet { * @note The column index or key index is passed as an input parameter. * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param columnOrKeyIndex Indicates the index of the specified column or key in the result set. + * @param columnIndex Indicates the index of the specified column or key in the result set. * @return Returns the name of the specified column or key. */ - getColumnOrKeyName(columnOrKeyIndex: number): string; + getColumnName(columnIndex: number): string; /** * Obtains the dataType of the specified column or key. @@ -363,8 +265,8 @@ export default interface DataShareResultSet { * column or key in the current row is null, the specified column or key is not in the data type. * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @param columnOrKeyIndex Indicates the specified column index or key index, which starts from 0. + * @param columnIndex Indicates the specified column index or key index, which starts from 0. * @return Returns the dataType of the specified column or key. */ - getDataType(columnOrKeyIndex: number): DataType; + getDataType(columnIndex: number): DataType; } \ No newline at end of file diff --git a/api/@ohos.data.ValuesBucket.d.ts b/api/@ohos.data.ValuesBucket.d.ts new file mode 100644 index 0000000000..32a6025be8 --- /dev/null +++ b/api/@ohos.data.ValuesBucket.d.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Indicates possible value types + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import N/A + */ +export type ValueType = number | string | boolean; + +/** + * Values in buckets are stored in key-value pairs + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.DataShare.Core + * @import N/A + */ +export type ValuesBucket = { + [key: string]: ValueType | Uint8Array | null; +} \ No newline at end of file diff --git a/api/@ohos.data.dataShare.d.ts b/api/@ohos.data.dataShare.d.ts index e6c3f0c01d..374d1bde49 100644 --- a/api/@ohos.data.dataShare.d.ts +++ b/api/@ohos.data.dataShare.d.ts @@ -18,7 +18,7 @@ import { Want } from './ability/want'; import Context from './application/Context'; import DataShareResultSet from './@ohos.data.DataShareResultSet'; import DataSharePredicates from './@ohos.data.DataSharePredicates'; -import { DataShareValuesBucket } from './@ohos.data.DataShareValuesBucket'; +import { ValuesBucket } from './@ohos.data.ValuesBucket'; declare namespace dataShare { /** @@ -30,7 +30,8 @@ declare namespace dataShare { * @param uri Indicates the path of the file to open. * @return Returns the dataShareHelper. */ - function createDataShareHelper(context: Context, want: Want, uri: string): DataShareHelper; + function createDataShareHelper(context: Context, want: Want, uri: string, callback: AsyncCallback): void; + function createDataShareHelper(context: Context, want: Want, uri: string): Promise; /** * DataShareHelper @@ -55,6 +56,7 @@ declare namespace dataShare { */ openFile(uri: string, mode: string, callback: AsyncCallback): void; openFile(uri: string, mode: string): Promise; + /** * Registers an observer to observe data specified by the given uri. * @since 9 @@ -88,8 +90,8 @@ declare namespace dataShare { * @return Returns the index of the inserted data record. * @StageModelOnly */ - insert(uri: string, value: DataShareValuesBucket, callback: AsyncCallback): void; - insert(uri: string, value: DataShareValuesBucket): Promise; + insert(uri: string, value: ValuesBucket, callback: AsyncCallback): void; + insert(uri: string, value: ValuesBucket): Promise; /** * Deletes one or more data records from the database. @@ -103,14 +105,13 @@ declare namespace dataShare { delete(uri: string, predicates: DataSharePredicates, callback: AsyncCallback): void; delete(uri: string, predicates: DataSharePredicates): Promise; - /** * Queries data in the database. * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @param uri Indicates the path of data to query. - * @param columns Indicates the columns to query. If this parameter is null, all columns are queried. * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. + * @param columns Indicates the columns to query. If this parameter is null, all columns are queried. * @return Returns the query result. * @StageModelOnly */ @@ -127,9 +128,8 @@ declare namespace dataShare { * @return Returns the number of data records updated. * @StageModelOnly */ - update(uri: string, value: DataShareValuesBucket, predicates: DataSharePredicates, callback: AsyncCallback): void; - update(uri: string, value: DataShareValuesBucket, predicates: DataSharePredicates): Promise; - + update(uri: string, value: ValuesBucket, predicates: DataSharePredicates, callback: AsyncCallback): void; + update(uri: string, value: ValuesBucket, predicates: DataSharePredicates): Promise; /** * Inserts multiple data records into the database. @@ -140,8 +140,8 @@ declare namespace dataShare { * @return Returns the number of data records inserted. * @StageModelOnly */ - batchInsert(uri: string, values: Array, callback: AsyncCallback): void; - batchInsert(uri: string, values: Array): Promise; + batchInsert(uri: string, values: Array, callback: AsyncCallback): void; + batchInsert(uri: string, values: Array): Promise; /** * Obtains the MIME type of the date specified by the given uri. -- Gitee From 21848523987316de6115dd02da39dcbbe3b2a95b Mon Sep 17 00:00:00 2001 From: duanweiling Date: Thu, 12 May 2022 08:37:37 +0800 Subject: [PATCH 5/7] =?UTF-8?q?JS=20API=20=E6=8E=A5=E5=8F=A3=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- api/@ohos.data.DataShareValuesBucket.d.ts | 34 ----------------------- 1 file changed, 34 deletions(-) delete mode 100644 api/@ohos.data.DataShareValuesBucket.d.ts diff --git a/api/@ohos.data.DataShareValuesBucket.d.ts b/api/@ohos.data.DataShareValuesBucket.d.ts deleted file mode 100644 index 4ed509b54a..0000000000 --- a/api/@ohos.data.DataShareValuesBucket.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Indicates possible value types - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @import N/A - */ -export type ValueType = number | string | boolean; - -/** - * Values in buckets are stored in key-value pairs - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.DataShare.Core - * @import N/A - */ -export type DataShareValuesBucket = { - [key: string]: ValueType | Uint8Array | null; -} \ No newline at end of file -- Gitee From f7242e4938c68f7694aef48b985f6703518ae9ed Mon Sep 17 00:00:00 2001 From: wuyongning Date: Thu, 12 May 2022 15:04:19 +0800 Subject: [PATCH 6/7] add datashare interfaces Signed-off-by: wuyongning --- api/@ohos.data.rdb.d.ts | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index 0244e6b8c1..915a140130 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -16,6 +16,8 @@ import {AsyncCallback, Callback} from './basic'; import { ResultSet } from './data/rdb/resultSet'; import Context from "./application/Context"; +import DataSharePredicates from './@ohos.data.DataSharePredicates'; +import { DataShareValuesBucket } from "./@ohos.data.DataShareValuesBucket"; /** * Provides methods for rdbStore create and delete. @@ -123,6 +125,19 @@ declare namespace rdb { insert(name: string, values: ValuesBucket, callback: AsyncCallback): void; insert(name: string, values: ValuesBucket): Promise; + /** + * Inserts a row of data into the target table. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param name Indicates the target 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. + */ + insert(name: string, values: DataShareValuesBucket, callback: AsyncCallback): void; + insert(name: string, values: DataShareValuesBucket): Promise; + /** * Updates data in the database based on a a specified instance object of rdbPredicates. * @@ -136,6 +151,20 @@ declare namespace rdb { update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallback): void; update(values: ValuesBucket, rdbPredicates: RdbPredicates): Promise; + /** + * Updates data in the database based on a a specified instance object of rdbPredicates. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param name Indicates the target 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 predicates Indicates the specified update condition by the instance object of RdbPredicates. + * @return Returns the number of affected rows. + */ + update(name: string, values: DataShareValuesBucket, predicates: DataSharePredicates, callback: AsyncCallback): void; + update(name: string, values: DataShareValuesBucket, predicates: DataSharePredicates): Promise; + /** * Deletes data from the database based on a specified instance object of rdbPredicates. * @@ -148,6 +177,19 @@ declare namespace rdb { delete(rdbPredicates: RdbPredicates, callback: AsyncCallback): void; delete(rdbPredicates: RdbPredicates): Promise; + /** + * Deletes data from the database based on a specified instance object of rdbPredicates. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param name Indicates the target table. + * @param predicates Indicates the specified delete condition by the instance object of RdbPredicates. + * @return Returns the number of affected rows. + */ + delete(name: string, predicates: DataSharePredicates, callback: AsyncCallback): void; + delete(name: string, predicates: DataSharePredicates): Promise; + /** * Queries data in the database based on specified conditions. * @@ -161,6 +203,19 @@ declare namespace rdb { query(rdbPredicates: RdbPredicates, columns: Array, callback: AsyncCallback): void; query(rdbPredicates: RdbPredicates, columns?: Array): Promise; + /** + * Queries data in the database based on specified conditions. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param predicates 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. + * @return Returns a ResultSet object if the operation is successful; + */ + query(name: string, predicates: DataSharePredicates, columns: Array, callback: AsyncCallback): void; + query(name: string, predicates: DataSharePredicates, columns?: Array): Promise; + /** * Queries data in the database based on SQL statement. * -- Gitee From 7fa7a2b27b3b8bda796fb7ad4f93cb00058a23db Mon Sep 17 00:00:00 2001 From: wuyongning Date: Thu, 12 May 2022 15:29:03 +0800 Subject: [PATCH 7/7] updatewq Signed-off-by: wuyongning --- api/@ohos.data.rdb.d.ts | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index 915a140130..42724c758c 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -17,7 +17,7 @@ import {AsyncCallback, Callback} from './basic'; import { ResultSet } from './data/rdb/resultSet'; import Context from "./application/Context"; import DataSharePredicates from './@ohos.data.DataSharePredicates'; -import { DataShareValuesBucket } from "./@ohos.data.DataShareValuesBucket"; +import { ValueType, ValuesBucket } from './@ohos.data.ValuesBucket'; /** * Provides methods for rdbStore create and delete. @@ -135,8 +135,8 @@ declare namespace rdb { * @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. */ - insert(name: string, values: DataShareValuesBucket, callback: AsyncCallback): void; - insert(name: string, values: DataShareValuesBucket): Promise; + insert(name: string, values: ValuesBucket, callback: AsyncCallback): void; + insert(name: string, values: ValuesBucket): Promise; /** * Updates data in the database based on a a specified instance object of rdbPredicates. @@ -162,8 +162,8 @@ declare namespace rdb { * @param predicates Indicates the specified update condition by the instance object of RdbPredicates. * @return Returns the number of affected rows. */ - update(name: string, values: DataShareValuesBucket, predicates: DataSharePredicates, callback: AsyncCallback): void; - update(name: string, values: DataShareValuesBucket, predicates: DataSharePredicates): Promise; + update(name: string, values: ValuesBucket, predicates: DataSharePredicates, callback: AsyncCallback): void; + update(name: string, values: ValuesBucket, predicates: DataSharePredicates): Promise; /** * Deletes data from the database based on a specified instance object of rdbPredicates. @@ -335,26 +335,6 @@ declare namespace rdb { off(event:'dataChange', type: SubscribeType, observer: Callback>): void; } - /** - * Indicates possible value types - * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @import import data_rdb from '@ohos.data.rdb'; - */ - type ValueType = number | string | boolean; - - /** - * Values in buckets are stored in key-value pairs - * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @import import data_rdb from '@ohos.data.rdb'; - */ - type ValuesBucket = { - [key: string]: ValueType | Uint8Array | null; - } - /** * Manages relational database configurations. * -- Gitee