mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2024-11-30 10:53:31 +00:00
js API 接口参数修改
Signed-off-by: duanweiling <duanweiling@huawei.com>
This commit is contained in:
parent
1f8b450522
commit
f4617d9bd3
@ -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<number>): void;
|
||||
insert?(uri: string, valueBucket: DataShareValuesBucket, callback: AsyncCallback<number>): 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<number>): 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<number>): void;
|
||||
delete?(uri: string, predicates: DataSharePredicates, callback: AsyncCallback<number>): 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<string>, predicates: dataAbility.DataAbilityPredicates,
|
||||
callback: AsyncCallback<ResultSet>): void;
|
||||
query?(uri: string, columns: Array<string>, predicates: DataSharePredicates,
|
||||
callback: AsyncCallback<DataShareResultSet>): 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<rdb.ValuesBucket>, callback: AsyncCallback<number>): void;
|
||||
batchInsert?(uri: string, valueBuckets: Array<DataShareValuesBucket>,
|
||||
callback: AsyncCallback<number>): void;
|
||||
|
||||
/**
|
||||
* Converts the given {@code uri} that refer to the data share into a normalized URI. A normalized URI can be
|
||||
|
443
api/@ohos.data.DataSharePredicates.d.ts
vendored
Normal file
443
api/@ohos.data.DataSharePredicates.d.ts
vendored
Normal file
@ -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<string>): 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<ValueType>): 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<ValueType>): 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<string>): 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;
|
370
api/@ohos.data.DataShareResultSet.d.ts
vendored
Normal file
370
api/@ohos.data.DataShareResultSet.d.ts
vendored
Normal file
@ -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}.
|
||||
*
|
||||
* <p>{@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<string>;
|
||||
|
||||
/**
|
||||
* 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<string>;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
34
api/@ohos.data.DataShareValuesBucket.d.ts
vendored
Normal file
34
api/@ohos.data.DataShareValuesBucket.d.ts
vendored
Normal file
@ -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;
|
||||
}
|
32
api/@ohos.data.dataShare.d.ts
vendored
32
api/@ohos.data.dataShare.d.ts
vendored
@ -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<number>): void;
|
||||
insert(uri: string, value: rdb.ValuesBucket): Promise<number>;
|
||||
insert(uri: string, value: DataShareValuesBucket, callback: AsyncCallback<number>): void;
|
||||
insert(uri: string, value: DataShareValuesBucket): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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<number>): void;
|
||||
delete(uri: string, predicates: dataAbility.DataAbilityPredicates): Promise<number>;
|
||||
delete(uri: string, predicates: DataSharePredicates, callback: AsyncCallback<number>): void;
|
||||
delete(uri: string, predicates: DataSharePredicates): Promise<number>;
|
||||
|
||||
|
||||
/**
|
||||
@ -114,8 +114,8 @@ declare namespace dataShare {
|
||||
* @return Returns the query result.
|
||||
* @StageModelOnly
|
||||
*/
|
||||
query(uri: string, columns: Array<string>, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback<ResultSet>): void;
|
||||
query(uri: string, columns: Array<string>, predicates: dataAbility.DataAbilityPredicates): Promise<ResultSet>;
|
||||
query(uri: string, columns: Array<string>, predicates: DataSharePredicates, callback: AsyncCallback<DataShareResultSet>): void;
|
||||
query(uri: string, columns: Array<string>, predicates: DataSharePredicates): Promise<DataShareResultSet>;
|
||||
|
||||
/**
|
||||
* 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<number>): void;
|
||||
update(uri: string, value: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates): Promise<number>;
|
||||
update(uri: string, value: DataShareValuesBucket, predicates: DataSharePredicates, callback: AsyncCallback<number>): void;
|
||||
update(uri: string, value: DataShareValuesBucket, predicates: DataSharePredicates): Promise<number>;
|
||||
|
||||
|
||||
/**
|
||||
@ -140,8 +140,8 @@ declare namespace dataShare {
|
||||
* @return Returns the number of data records inserted.
|
||||
* @StageModelOnly
|
||||
*/
|
||||
batchInsert(uri: string, values: Array<rdb.ValuesBucket>, callback: AsyncCallback<number>): void;
|
||||
batchInsert(uri: string, values: Array<rdb.ValuesBucket>): Promise<number>;
|
||||
batchInsert(uri: string, values: Array<DataShareValuesBucket>, callback: AsyncCallback<number>): void;
|
||||
batchInsert(uri: string, values: Array<DataShareValuesBucket>): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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<Array<string>>;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* <p>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.
|
||||
|
Loading…
Reference in New Issue
Block a user