diff --git a/api/@ohos.data.distributedKVStore.d.ts b/api/@ohos.data.distributedKVStore.d.ts index 49a44cf505a82634bde2362987295387b84eebc4..1f261f895ed16e0a3af69aa050e893cddbeca6ec 100644 --- a/api/@ohos.data.distributedKVStore.d.ts +++ b/api/@ohos.data.distributedKVStore.d.ts @@ -1184,8 +1184,7 @@ declare namespace distributedKVStore { * @throws { BusinessError } 15100003 - Database corrupted. * @throws { BusinessError } 15100005 - Database or result set already closed. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ /** * Writes a key-value pair of the string type into the {@code SingleKVStore} database. @@ -1203,8 +1202,7 @@ declare namespace distributedKVStore { * @throws { BusinessError } 15100005 - Database or result set already closed. * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback): void; @@ -1223,8 +1221,7 @@ declare namespace distributedKVStore { * @throws { BusinessError } 15100003 - Database corrupted. * @throws { BusinessError } 15100005 - Database or result set already closed. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ /** * Writes a key-value pair of the string type into the {@code SingleKVStore} database. @@ -1242,11 +1239,52 @@ declare namespace distributedKVStore { * @throws { BusinessError } 15100005 - Database or result set already closed. * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ put(key: string, value: Uint8Array | string | number | boolean): Promise; + /** + * Writes a key-value pair of the string type into the {@code SingleKVStore} database. + *

If you do not want to synchronize this key-value pair to other devices, set the write option in the local + * database. + * + * @param { string } key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. + * Spaces before and after the key will be cleared. + * @param { Uint8Array | string | number | boolean } value - Indicates the value to be inserted. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameters types; + *
3.Parameter verification failed. + * @throws { BusinessError } 15100003 - Database corrupted. + * @throws { BusinessError } 15100005 - Database or result set already closed. + * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 20 + * @arkts 1.2 + */ + putWithCallback(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback): void; + + /** + * Writes a key-value pair of the string type into the {@code SingleKVStore} database. + *

If you do not want to synchronize this key-value pair to other devices, set the write option in the local + * database. + * + * @param { string } key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. + * Spaces before and after the key will be cleared. + * @param { Uint8Array | string | number | boolean } value - Indicates the value to be inserted. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameters types; + *
3.Parameter verification failed. + * @throws { BusinessError } 15100003 - Database corrupted. + * @throws { BusinessError } 15100005 - Database or result set already closed. + * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 20 + * @arkts 1.2 + */ + putReturnsPromise(key: string, value: Uint8Array | string | number | boolean): Promise; + /** * Inserts key-value pairs into the {@code SingleKVStore} database in batches. * @@ -1606,8 +1644,7 @@ declare namespace distributedKVStore { * @throws { BusinessError } 15100004 - Not found. * @throws { BusinessError } 15100005 - Database or result set already closed. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ get(key: string, callback: AsyncCallback): void; @@ -1624,11 +1661,46 @@ declare namespace distributedKVStore { * @throws { BusinessError } 15100004 - Not found. * @throws { BusinessError } 15100005 - Database or result set already closed. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ get(key: string): Promise; + /** + * Obtains the value of a specified key. + * + * @param { string } key - Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. + * @param { AsyncCallback } callback - + * {Uint8Array|string|boolean|number}: the returned value specified by the key. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameters types; + *
3.Parameter verification failed. + * @throws { BusinessError } 15100003 - Database corrupted. + * @throws { BusinessError } 15100004 - Not found. + * @throws { BusinessError } 15100005 - Database or result set already closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 20 + * @arkts 1.2 + */ + getWithCallback(key: string, callback: AsyncCallback): void; + + /** + * Obtains the value of a specified key. + * + * @param { string } key - Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. + * @returns { Promise } + * {Uint8Array|string|boolean|number}: the returned value specified by the key. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameters types; + *
3.Parameter verification failed. + * @throws { BusinessError } 15100003 - Database corrupted. + * @throws { BusinessError } 15100004 - Not found. + * @throws { BusinessError } 15100005 - Database or result set already closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 20 + * @arkts 1.2 + */ + getReturnsPromise(key: string): Promise; + /** * Obtains all key-value pairs that match a specified key prefix. * @@ -1963,8 +2035,7 @@ declare namespace distributedKVStore { *
2.Parameter verification failed. * @throws { BusinessError } 15100005 - Database or result set already closed. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ backup(file: string, callback: AsyncCallback): void; @@ -1978,11 +2049,40 @@ declare namespace distributedKVStore { *
2.Parameter verification failed. * @throws { BusinessError } 15100005 - Database or result set already closed. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ backup(file: string): Promise; + /** + * Backs up a database in the specified filename. + * + * @param { string } file - Indicates the database backup filename, It can not be empty and + * The length must be less than {@code MAX_KEY_LENGTH}. + * @param { AsyncCallback } callback - the callback of backup. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Parameter verification failed. + * @throws { BusinessError } 15100005 - Database or result set already closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 20 + * @arkts 1.2 + */ + backupWithCallback(file: string, callback: AsyncCallback): void; + + /** + * Backs up a database in the specified filename. + * + * @param { string } file - Indicates the database backup filename, It can not be empty and + * The length must be less than {@code MAX_KEY_LENGTH}. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Parameter verification failed. + * @throws { BusinessError } 15100005 - Database or result set already closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 20 + * @arkts 1.2 + */ + backupReturnsPromise(file: string): Promise; + /** * Restores a database from a specified database file. * @@ -2370,8 +2470,7 @@ declare namespace distributedKVStore { * @throws { BusinessError } 15100004 - Not found. * @throws { BusinessError } 15100005 - Database or result set already closed. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ get(key: string, callback: AsyncCallback): void; @@ -2388,11 +2487,45 @@ declare namespace distributedKVStore { * @throws { BusinessError } 15100004 - Not found. * @throws { BusinessError } 15100005 - Database or result set already closed. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ get(key: string): Promise; + /** + * Obtains the value matching the local device ID and specified key. + * + * @param { string } key - Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. + * @param { AsyncCallback } callback - + * {Uint8Array|string|boolean|number}: the returned value specified by the local device ID and specified key. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameters types; + *
3.Parameter verification failed. + * @throws { BusinessError } 15100003 - Database corrupted. + * @throws { BusinessError } 15100004 - Not found. + * @throws { BusinessError } 15100005 - Database or result set already closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 20 + * @arkts 1.2 + */ + getWithCallback(key: string, callback: AsyncCallback): void; + + /** + * Obtains the value matching the local device ID and specified key. + * + * @param { string } key - Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. + * @returns { Promise } + * {Uint8Array|string|boolean|number}: the returned value specified by the local device ID and specified key. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameters types; + *
3.Parameter verification failed. + * @throws { BusinessError } 15100003 - Database corrupted. + * @throws { BusinessError } 15100004 - Not found. + * @throws { BusinessError } 15100005 - Database or result set already closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 20 + * @arkts 1.2 + */ + getReturnsPromise(key: string): Promise; /** * Obtains the value matching a specified device ID and key. * @@ -2408,8 +2541,7 @@ declare namespace distributedKVStore { * @throws { BusinessError } 15100004 - Not found. * @throws { BusinessError } 15100005 - Database or result set already closed. * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since9 */ get(deviceId: string, key: string, callback: AsyncCallback): void; @@ -2428,11 +2560,51 @@ declare namespace distributedKVStore { * @throws { BusinessError } 15100004 - Not found. * @throws { BusinessError } 15100005 - Database or result set already closed. * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ get(deviceId: string, key: string): Promise; + /** + * Obtains the value matching a specified device ID and key. + * + * @param { string } deviceId - Indicates the device to be queried. + * @param { string } key - Indicates the key of the value to be queried. The length must be less than + * {@code MAX_KEY_LENGTH}. + * @param { AsyncCallback } callback - + * {boolean | string | number | Uint8Array}: the returned value specified by the deviceId and key. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameters types; + *
3.Parameter verification failed. + * @throws { BusinessError } 15100003 - Database corrupted. + * @throws { BusinessError } 15100004 - Not found. + * @throws { BusinessError } 15100005 - Database or result set already closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 20 + * @arkts 1.2 + */ + getByDevIdWithCallback(deviceId: string, key: string, + callback: AsyncCallback): void; + + /** + * Obtains the value matching a specified device ID and key. + * + * @param { string } deviceId - Indicates the device to be queried. + * @param { string } key - Indicates the key of the value to be queried. The length must be less than + * {@code MAX_KEY_LENGTH}. + * @returns { Promise } + * {Uint8Array|string|boolean|number}: the returned value specified by the deviceId and key. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameters types; + *
3.Parameter verification failed. + * @throws { BusinessError } 15100003 - Database corrupted. + * @throws { BusinessError } 15100004 - Not found. + * @throws { BusinessError } 15100005 - Database or result set already closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 20 + * @arkts 1.2 + */ + getByDevIdReturnsPromise(deviceId: string, key: string): Promise; + /** * Obtains all key-value pairs that match the local device ID and specified key prefix. * @@ -3110,8 +3282,7 @@ declare namespace distributedKVStore { * @throws { BusinessError } 15100002 - Open existed database with changed options. * @throws { BusinessError } 15100003 - Database corrupted. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ getKVStore(storeId: string, options: Options, callback: AsyncCallback): void; @@ -3130,11 +3301,50 @@ declare namespace distributedKVStore { * @throws { BusinessError } 15100002 - Open existed database with changed options. * @throws { BusinessError } 15100003 - Database corrupted. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ getKVStore(storeId: string, options: Options): Promise; + /** + * Creates and obtains a KVStore database by specifying {@code Options} and {@code storeId}. + * + * @param { string } storeId - Identifies the KVStore database. The value of this parameter must be unique + * for the same application, and different applications can share the same value. The storeId can consist + * of only letters, digits, and underscores (_), and cannot exceed 128 characters. + * @param { Options } options - Indicates the {@code Options} object used for creating and + * obtaining the KVStore database. + * @param { AsyncCallback } callback - {T}: the {@code SingleKVStore} or {@code DeviceKVStore} instance. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameters types; + *
3.Parameter verification failed. + * @throws { BusinessError } 15100002 - Open existed database with changed options. + * @throws { BusinessError } 15100003 - Database corrupted. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 20 + * @arkts 1.2 + */ + getKVStoreWithCallback(storeId: string, options: Options, callback: AsyncCallback): void; + + /** + * Creates and obtains a KVStore database by specifying {@code Options} and {@code storeId}. + * + * @param { string } storeId - Identifies the KVStore database. The value of this parameter must be unique + * for the same application, and different applications can share the same value. The storeId can consist + * of only letters, digits, and underscores (_), and cannot exceed 128 characters. + * @param { Options } options - Indicates the {@code Options} object used for creating and + * obtaining the KVStore database. + * @returns { Promise } {T}: the {@code SingleKVStore} or {@code DeviceKVStore} instance. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameters types; + *
3.Parameter verification failed. + * @throws { BusinessError } 15100002 - Open existed database with changed options. + * @throws { BusinessError } 15100003 - Database corrupted. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 20 + * @arkts 1.2 + */ + getKVStoreReturnsPromise(storeId: string, options: Options): Promise; + /** * Closes the KVStore database. *

Warning: This method is not thread-safe. If you call this method to stop a KVStore database that is running,