• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import{ AsyncCallback, Callback } from './basic';
17import Context from "./application/BaseContext";
18import dataSharePredicates from './@ohos.data.dataSharePredicates';
19
20/**
21 * Provides methods for rdbStore create and delete.
22 *
23 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
24 * @since 9
25 */
26declare namespace relationalStore
27{
28    /**
29     * Obtains a RDB store.
30     *
31     * You can set parameters of the RDB store as required. In general, this method is recommended
32     * to obtain a rdb store.
33     *
34     * @param {Context} context - indicates the context of application or capability.
35     * @param {StoreConfig} config - indicates the {@link StoreConfig} configuration of the database related to this RDB store.
36     * @param {AsyncCallback<RdbStore>} callback - the RDB store {@link RdbStore}.
37     * @throws {BusinessError} 401 - Parameter error.
38     * @throws {BusinessError} 14800000 - The inner error is occurred.
39     * @throws {BusinessError} 14800010 - Failed to open database by invalid database path.
40     * @throws {BusinessError} 14800011 - Failed open database, database corrupted.
41     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
42     * @since 9
43     */
44    function getRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback<RdbStore>): void;
45
46    /**
47     * Obtains a RDB store.
48     *
49     * You can set parameters of the RDB store as required. In general, this method is recommended
50     * to obtain a rdb store.
51     *
52     * @param {Context} context - indicates the context of application or capability.
53     * @param {StoreConfig} config - indicates the {@link StoreConfig} configuration of the database related to this RDB store.
54     * @returns {Promise<RdbStore>} the RDB store {@link RdbStore}.
55     * @throws {BusinessError} 401 - Parameter error.
56     * @throws {BusinessError} 14800000 - The inner error is occurred.
57     * @throws {BusinessError} 14800010 - Failed to open database by invalid database path.
58     * @throws {BusinessError} 14800011 - Failed open database, database corrupted.
59     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
60     * @since 9
61     */
62    function getRdbStore(context: Context, config: StoreConfig): Promise<RdbStore>;
63
64    /**
65     * Deletes the database with a specified name.
66     *
67     * @param {Context} context - indicates the context of application or capability.
68     * @param {string} name - indicates the database name.
69     * @param {AsyncCallback<void>} callback - the callback of deleteRdbStore.
70     * @throws {BusinessError} 401 - Parameter error.
71     * @throws {BusinessError} 14800000 - The inner error is occurred.
72     * @throws {BusinessError} 14800010 - Failed to open or delete database by invalid database path.
73     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
74     * @since 9
75     */
76    function deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void>): void;
77
78    /**
79     * Deletes the database with a specified name.
80     *
81     * @param {Context} context - indicates the context of application or capability.
82     * @param {string} name - indicates the database name.
83     * @returns {Promise<void>} the promise returned by the function.
84     * @throws {BusinessError} 401 - Parameter error.
85     * @throws {BusinessError} 14800000 - The inner error is occurred.
86     * @throws {BusinessError} 14800010 - Failed to open or delete database by invalid database path.
87     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
88     * @since 9
89     */
90    function deleteRdbStore(context: Context, name: string): Promise<void>;
91
92    /**
93     * Manages relational database configurations.
94     *
95     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
96     * @since 9
97     */
98    interface StoreConfig {
99        /**
100         * The database name.
101         *
102         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
103         * @since 9
104         */
105        name: string;
106
107        /**
108         * Specifies the security level of the database.
109         *
110         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
111         * @since 9
112         */
113        securityLevel: SecurityLevel;
114
115        /**
116         * Specifies whether the database is encrypted.
117         *
118         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
119         * @since 9
120         */
121        encrypt ?: boolean;
122    }
123
124    /**
125     * Describes the {@code RdbStore} type.
126     *
127     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
128     * @since 9
129     */
130    enum SecurityLevel {
131        /**
132         * S1: means the db is low level security
133         * There are some low impact, when the data is leaked.
134         *
135         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
136         * @since 9
137         */
138         S1 = 1,
139
140         /**
141          * S2: means the db is middle level security
142          * There are some major impact, when the data is leaked.
143          *
144          * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
145          * @since 9
146          */
147         S2 = 2,
148
149         /**
150          * S3: means the db is high level security
151          * There are some severity impact, when the data is leaked.
152          *
153          * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
154          * @since 9
155          */
156         S3 = 3,
157
158         /**
159          * S4: means the db is critical level security
160          * There are some critical impact, when the data is leaked.
161          *
162          * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
163          * @since 9
164          */
165         S4 = 4,
166    }
167
168    /**
169     * Indicates possible value types
170     *
171     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
172     * @since 9
173     */
174    type ValueType = number | string | boolean | Uint8Array;
175
176    /**
177     * Values in buckets are stored in key-value pairs
178     *
179     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
180     * @since 9
181     */
182    type ValuesBucket = { [key:string]: ValueType | Uint8Array | null;}
183
184    /**
185     * Indicates the database synchronization mode.
186     *
187     * @since 9
188     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
189     */
190    enum SyncMode {
191        /**
192         * Indicates the data is pushed to remote device from local device.
193         *
194         * @since 9
195         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
196         */
197        SYNC_MODE_PUSH = 0,
198
199        /**
200         * Indicates the data is pulled from remote device to local device.
201         *
202         * @since 9
203         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
204         */
205        SYNC_MODE_PULL = 1,
206    }
207
208    /**
209     * Describes the subscription type.
210     *
211     * @since 9
212     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
213     * @permission ohos.permission.DISTRIBUTED_DATASYNC
214     */
215    enum SubscribeType {
216        /**
217         * Subscription to remote data changes
218         * @since 9
219         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
220         */
221        SUBSCRIBE_TYPE_REMOTE = 0,
222    }
223
224    /**
225     * Provides methods for managing the relational database (RDB).
226     *
227     * This class provides methods for creating, querying, updating, and deleting RDBs.
228     *
229     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
230     * @since 9
231     */
232    interface RdbStore {
233        /**
234         * Inserts a row of data into the target table.
235         *
236         * @param {string} table - indicates the target table.
237         * @param {ValuesBucket} values - indicates the row of data {@link ValuesBucket} to be inserted into the table.
238         * @param {AsyncCallback<number>} callback - the row ID if the operation is successful. returns -1 otherwise.
239         * @throws {BusinessError} 401 - Parameter error.
240         * @throws {BusinessError} 14800000 - The inner error is occurred.
241         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
242         * @since 9
243         */
244        insert(table: string, values: ValuesBucket, callback: AsyncCallback<number>): void;
245
246        /**
247         * Inserts a row of data into the target table.
248         *
249         * @param {string} table - indicates the target table.
250         * @param {ValuesBucket} values - indicates the row of data {@link ValuesBucket} to be inserted into the table.
251         * @returns {Promise<void>} the row ID if the operation is successful. return -1 otherwise.
252         * @throws {BusinessError} 401 - Parameter error.
253         * @throws {BusinessError} 14800000 - The inner error is occurred.
254         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
255         * @since 9
256         */
257        insert(table: string, values: ValuesBucket): Promise<number>;
258
259        /**
260         * Inserts a batch of data into the target table.
261         *
262         * @param {string} table - indicates the target table.
263         * @param {Array<ValuesBucket>} values - indicates the rows of data {@link ValuesBucket} to be inserted into the table.
264         * @param {AsyncCallback<number>} callback - the number of values that were inserted if the operation is successful. returns -1 otherwise.
265         * @throws {BusinessError} 401 - Parameter error.
266         * @throws {BusinessError} 14800000 - The inner error is occurred.
267         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
268         * @since 9
269         */
270        batchInsert(table: string, values: Array<ValuesBucket>, callback: AsyncCallback<number>): void;
271
272        /**
273         * Inserts a batch of data into the target table.
274         *
275         * @param {string} table - indicates the target table.
276         * @param {Array<ValuesBucket>} values - indicates the rows of data {@link ValuesBucket} to be inserted into the table.
277         * @returns {Promise<void>} the number of values that were inserted if the operation is successful. returns -1 otherwise.
278         * @throws {BusinessError} 401 - Parameter error.
279         * @throws {BusinessError} 14800000 - The inner error is occurred.
280         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
281         * @since 9
282         */
283        batchInsert(table: string, values: Array<ValuesBucket>): Promise<number>;
284
285        /**
286         * Updates data in the database based on a specified instance object of RdbPredicates.
287         *
288         * @param {ValuesBucket} 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.
289         * @param {RdbPredicates} predicates - indicates the specified update condition by the instance object of  {@link RdbPredicates}.
290         * @param {AsyncCallback<number>} callback - the number of affected rows.
291         * @throws {BusinessError} 401 - Parameter error.
292         * @throws {BusinessError} 14800000 - The inner error is occurred.
293         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
294         * @since 9
295         */
296        update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback<number>): void;
297
298        /**
299         * Updates data in the database based on a specified instance object of RdbPredicates.
300         *
301         * @param {ValuesBucket} 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.
302         * @param {RdbPredicates} predicates - indicates the specified update condition by the instance object of  {@link RdbPredicates}.
303         * @returns {Promise<number>} the number of affected rows.
304         * @throws {BusinessError} 401 - Parameter error.
305         * @throws {BusinessError} 14800000 - The inner error is occurred.
306         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
307         * @since 9
308         */
309        update(values: ValuesBucket, predicates: RdbPredicates): Promise<number>;
310
311        /**
312         * Updates data in the database based on a specified instance object of RdbPredicates.
313         *
314         * @param {string} table - indicates the target table.
315         * @param {ValuesBucket} 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.
316         * @param {DataSharePredicates} predicates - indicates the specified update condition by the instance object of {@link dataSharePredicates.DataSharePredicates}.
317         * @param {AsyncCallback<number>} callback - the number of affected rows.
318         * @throws {BusinessError} 401 - Parameter error.
319         * @throws {BusinessError} 14800000 - The inner error is occurred.
320         * @throws {BusinessError} 202 - if permission verification failed, application which is not a system application uses system API.
321         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
322         * @systemapi
323         * @StageModelOnly
324         * @since 9
325         */
326        update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>): void;
327
328        /**
329         * Updates data in the database based on a specified instance object of RdbPredicates.
330         *
331         * @param {string} table - indicates the target table.
332         * @param {ValuesBucket} 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.
333         * @param {DataSharePredicates} predicates - indicates the specified update condition by the instance object of {@link dataSharePredicates.DataSharePredicates}.
334         * @returns {Promise<number>} the number of affected rows.
335         * @throws {BusinessError} 401 - Parameter error.
336         * @throws {BusinessError} 14800000 - The inner error is occurred.
337         * @throws {BusinessError} 202 - if permission verification failed, application which is not a system application uses system API.
338         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
339         * @systemapi
340         * @StageModelOnly
341         * @since 9
342         */
343        update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates): Promise<number>;
344
345        /**
346         * Deletes data from the database based on a specified instance object of RdbPredicates.
347         *
348         * @param {RdbPredicates} predicates - the specified delete condition by the instance object of {@link RdbPredicates}.
349         * @param {AsyncCallback<number>} callback - the number of affected rows.
350         * @throws {BusinessError} 401 - Parameter error.
351         * @throws {BusinessError} 14800000 - The inner error is occurred.
352         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
353         * @since 9
354         */
355        delete(predicates: RdbPredicates, callback: AsyncCallback<number>): void;
356
357        /**
358         * Deletes data from the database based on a specified instance object of RdbPredicates.
359         *
360         * @param {RdbPredicates} predicates - the specified delete condition by the instance object of {@link RdbPredicates}.
361         * @returns {Promise<number>} the number of affected rows.
362         * @throws {BusinessError} 401 - Parameter error.
363         * @throws {BusinessError} 14800000 - The inner error is occurred.
364         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
365         * @since 9
366         */
367        delete(predicates: RdbPredicates): Promise<number>;
368
369        /**
370         * Deletes data from the database based on a specified instance object of RdbPredicates.
371         *
372         * @param {string} table - indicates the target table.
373         * @param {DataSharePredicates} predicates - the specified delete condition by the instance object of {@link dataSharePredicates.DataSharePredicates}.
374         * @param {AsyncCallback<number>} callback - the number of affected rows.
375         * @throws {BusinessError} 401 - Parameter error.
376         * @throws {BusinessError} 14800000 - The inner error is occurred.
377         * @throws {BusinessError} 202 - if permission verification failed, application which is not a system application uses system API.
378         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
379         * @systemapi
380         * @StageModelOnly
381         * @since 9
382         */
383        delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>): void;
384
385        /**
386         * Deletes data from the database based on a specified instance object of RdbPredicates.
387         *
388         * @param {string} table - indicates the target table.
389         * @param {DataSharePredicates} predicates - the specified delete condition by the instance object of {@link dataSharePredicates.DataSharePredicates}.
390         * @returns {Promise<number>} the number of affected rows.
391         * @throws {BusinessError} 401 - Parameter error.
392         *  @throws {BusinessError} 14800000 - The inner error is occurred.
393         * @throws {BusinessError} 202 - if permission verification failed, application which is not a system application uses system API.
394         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
395         * @systemapi
396         * @StageModelOnly
397         * @since 9
398         */
399        delete(table: string, predicates: dataSharePredicates.DataSharePredicates): Promise<number>;
400
401        /**
402         * Queries data in the database based on specified conditions.
403         *
404         * @param {RdbPredicates} predicates - the specified query condition by the instance object of {@link RdbPredicates}.
405         * @param {Array<string>} columns - the columns to query. If the value is empty array, the query applies to all columns.
406         * @param {AsyncCallback<ResultSet>} callback - the {@link ResultSet} object if the operation is successful.
407         * @throws {BusinessError} 401 - Parameter error.
408         * @throws {BusinessError} 14800000 - The inner error is occurred.
409         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
410         * @since 9
411         */
412        query(predicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>): void;
413
414        /**
415         * Queries data in the database based on specified conditions.
416         *
417         * @param {RdbPredicates} predicates - the specified query condition by the instance object of {@link RdbPredicates}.
418         * @param {Array<string>} columns - the columns to query. If the value is null, the query applies to all columns.
419         * @returns {Promise<ResultSet>} the {@link ResultSet} object if the operation is successful.
420         * @throws {BusinessError} 401 - Parameter error.
421         * @throws {BusinessError} 14800000 - The inner error is occurred.
422         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
423         * @since 9
424         */
425        query(predicates: RdbPredicates, columns ?: Array<string>): Promise<ResultSet>;
426
427        /**
428         * Queries data in the database based on specified conditions.
429         *
430         * @param {string} table - indicates the target table.
431         * @param {dataSharePredicates.DataSharePredicates} predicates - the specified query condition by the instance object of {@link dataSharePredicates.DataSharePredicates}.
432         * @param {Array<string>} columns - the columns to query. If the value is empty array, the query applies to all columns.
433         * @param {AsyncCallback<ResultSet>} callback - the {@link ResultSet} object if the operation is successful.
434         * @throws {BusinessError} 401 - Parameter error.
435         * @throws {BusinessError} 14800000 - The inner error is occurred.
436         * @throws {BusinessError} 202 - if permission verification failed, application which is not a system application uses system API.
437         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
438         * @systemapi
439         * @StageModelOnly
440         * @since 9
441         */
442        query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>): void;
443
444        /**
445         * Queries data in the database based on specified conditions.
446         *
447         * @param {string} table - indicates the target table.
448         * @param {dataSharePredicates.DataSharePredicates} predicates - the specified query condition by the instance object of {@link dataSharePredicates.DataSharePredicates}.
449         * @param {Array<string>} columns - the columns to query. If the value is null, the query applies to all columns.
450         * @returns {Promise<ResultSet>} the {@link ResultSet} object if the operation is successful.
451         * @throws {BusinessError} 401 - Parameter error.
452         * @throws {BusinessError} 14800000 - The inner error is occurred.
453         * @throws {BusinessError} 202 - if permission verification failed, application which is not a system application uses system API.
454         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
455         * @systemapi
456         * @StageModelOnly
457         * @since 9
458         */
459        query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns ?: Array<string>): Promise<ResultSet>;
460
461        /**
462         * Queries data in the database based on SQL statement.
463         *
464         * @param {string} sql - indicates the SQL statement to execute.
465         * @param {Array<ValueType>} bindArgs - indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings.
466         * @param {AsyncCallback<ResultSet>} callback - the {@link ResultSet} object if the operation is successful.
467         * @throws {BusinessError} 401 - Parameter error.
468         * @throws {BusinessError} 14800000 - The inner error is occurred.
469         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
470         * @since 9
471         */
472        querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<ResultSet>): void;
473
474        /**
475         * Queries data in the database based on SQL statement.
476         *
477         * @param {string} sql - indicates the SQL statement to execute.
478         * @param {Array<ValueType>} bindArgs - indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings.
479         * @returns {Promise<ResultSet>} the {@link ResultSet} object if the operation is successful.
480         * @throws {BusinessError} 401 - Parameter error.
481         * @throws {BusinessError} 14800000 - The inner error is occurred.
482         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
483         * @since 9
484         */
485        querySql(sql: string, bindArgs ?: Array<ValueType>): Promise<ResultSet>;
486
487        /**
488         * Executes a SQL statement that contains specified parameters but returns no value.
489         *
490         * @param {string} sql - indicates the SQL statement to execute.
491         * @param {Array<ValueType>} bindArgs - indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings.
492         * @param {AsyncCallback<void>} callback - the callback of executeSql.
493         * @throws {BusinessError} 401 - Parameter error.
494         * @throws {BusinessError} 14800000 - The inner error is occurred.
495         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
496         * @since 9
497         */
498        executeSql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<void>): void;
499
500        /**
501         * Executes a SQL statement that contains specified parameters but returns no value.
502         *
503         * @param {string} sql - indicates the SQL statement to execute.
504         * @param {Array<ValueType>} bindArgs - indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings.
505         * @returns {Promise<void>} the promise returned by the function.
506         * @throws {BusinessError} 401 - Parameter error.
507         * @throws {BusinessError} 14800000 - The inner error is occurred.
508         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
509         * @since 9
510         */
511        executeSql(sql: string, bindArgs ?: Array<ValueType>): Promise<void>;
512
513        /**
514         * BeginTransaction before execute your sql.
515         *
516         * @throws {BusinessError} 401 - Parameter error.
517         * @throws {BusinessError} 14800000 - The inner error is occurred.
518         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
519         * @since 9
520         */
521        beginTransaction(): void;
522
523        /**
524         * Commit the the sql you have executed.
525         *
526         * @throws {BusinessError} 401 - Parameter error.
527         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
528         * @since 9
529         */
530        commit(): void;
531
532        /**
533         * Roll back the sql you have already executed.
534         *
535         * @throws {BusinessError} 401 - Parameter error.
536         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
537         * @since 9
538         */
539        rollBack(): void;
540
541        /**
542         * Backs up a database in a specified name.
543         *
544         * @param {string} destName - indicates the name that saves the database backup.
545         * @param {AsyncCallback<void>} callback - the callback of backup.
546         * @throws {BusinessError} 401 - Parameter error.
547         * @throws {BusinessError} 14800000 - The inner error is occurred.
548         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
549         * @since 9
550         */
551        backup(destName: string, callback: AsyncCallback<void>): void;
552
553        /**
554         * Backs up a database in a specified name.
555         *
556         * @param {string} destName - indicates the name that saves the database backup.
557         * @returns {Promise<void>} the promise returned by the function.
558         * @throws {BusinessError} 401 - Parameter error.
559         * @throws {BusinessError} 14800000 - The inner error is occurred.
560         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
561         * @since 9
562         */
563        backup(destName: string): Promise<void>;
564
565        /**
566         * Restores a database from a specified database file.
567         *
568         * @param {string} srcName - indicates the name that saves the database file.
569         * @param {AsyncCallback<void>} callback - the callback of restore.
570         * @throws {BusinessError} 401 - Parameter error.
571         * @throws {BusinessError} 14800000 - The inner error is occurred.
572         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
573         * @since 9
574         */
575        restore(srcName: string, callback: AsyncCallback<void>): void;
576
577        /**
578         * Restores a database from a specified database file.
579         *
580         * @param {string} srcName - indicates the name that saves the database file.
581         * @returns {Promise<void>} the promise returned by the function.
582         * @throws {BusinessError} 401 - Parameter error.
583         * @throws {BusinessError} 14800000 - The inner error is occurred.
584         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
585         * @since 9
586         */
587        restore(srcName: string): Promise<void>;
588
589        /**
590         * Set table to be distributed table.
591         *
592         * @permission ohos.permission.DISTRIBUTED_DATASYNC
593         * @param {Array<string>} tables - indicates the tables name you want to set.
594         * @param {AsyncCallback<void>} callback - the callback of setDistributedTables.
595         * @throws {BusinessError} 401 - Parameter error.
596         * @throws {BusinessError} 14800000 - The inner error is occurred.
597         * @throws {BusinessError} 801 - Capability not supported.
598         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
599         * @since 9
600         */
601        setDistributedTables(tables: Array<string>, callback: AsyncCallback<void>): void;
602
603        /**
604         * Set table to be distributed table.
605         *
606         * @permission ohos.permission.DISTRIBUTED_DATASYNC
607         * @param {Array<string>} tables - indicates the tables name you want to set.
608         * @returns {Promise<void>} the promise returned by the function.
609         * @throws {BusinessError} 401 - Parameter error.
610         * @throws {BusinessError} 14800000 - The inner error is occurred.
611         * @throws {BusinessError} 801 - Capability not supported.
612         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
613         * @since 9
614         */
615        setDistributedTables(tables: Array<string>): Promise<void>;
616
617        /**
618         * Obtain distributed table name of specified remote device according to local table name.
619         * When query remote device database, distributed table name is needed.
620         *
621         * @permission ohos.permission.DISTRIBUTED_DATASYNC
622         * @param {string} device - indicates the remote device.
623         * @param {AsyncCallback<string>} callback - {string}: the distributed table name.
624         * @throws {BusinessError} 401 - Parameter error.
625         * @throws {BusinessError} 14800000 - The inner error is occurred.
626         * @throws {BusinessError} 801 - Capability not supported.
627         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
628         * @since 9
629         */
630        obtainDistributedTableName(device: string, table: string, callback: AsyncCallback<string>): void;
631
632        /**
633         * Obtain distributed table name of specified remote device according to local table name.
634         * When query remote device database, distributed table name is needed.
635         *
636         * @permission ohos.permission.DISTRIBUTED_DATASYNC
637         * @param {string} device - indicates the remote device.
638         * @returns {Promise<string>} {string}: the distributed table name.
639         * @throws {BusinessError} 401 - Parameter error.
640         * @throws {BusinessError} 14800000 - The inner error is occurred.
641         * @throws {BusinessError} 801 - Capability not supported.
642         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
643         * @since 9
644         */
645        obtainDistributedTableName(device: string, table: string): Promise<string>;
646
647        /**
648         * Sync data between devices.
649         *
650         * @permission ohos.permission.DISTRIBUTED_DATASYNC
651         * @param {SyncMode} mode - indicates the database synchronization mode.
652         * @param {RdbPredicates} predicates - the specified sync condition by the instance object of {@link RdbPredicates}.
653         * @param {AsyncCallback<Array<[string, number]>>} callback - {Array<[string, number]>}: devices sync status array, {string}: device id, {number}: device sync status.
654         * @throws {BusinessError} 401 - Parameter error.
655         * @throws {BusinessError} 14800000 - The inner error is occurred.
656         * @throws {BusinessError} 801 - Capability not supported.
657         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
658         * @since 9
659         */
660        sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array<[ string, number ]>>): void;
661
662        /**
663         * Sync data between devices.
664         *
665         * @permission ohos.permission.DISTRIBUTED_DATASYNC
666         * @param {SyncMode} mode - indicates the database synchronization mode.
667         * @param {RdbPredicates} predicates - the specified sync condition by the instance object of {@link RdbPredicates}.
668         * @returns {Promise<Array<[string, number]>>} {Array<[string, number]>}: devices sync status array, {string}: device id, {number}: device sync status.
669         * @throws {BusinessError} 401 - Parameter error.
670         * @throws {BusinessError} 14800000 - The inner error is occurred.
671         * @throws {BusinessError} 801 - Capability not supported.
672         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
673         * @since 9
674         */
675        sync(mode: SyncMode, predicates: RdbPredicates): Promise<Array<[ string, number ]>>;
676
677        /**
678         * Queries remote data in the database based on specified conditions before Synchronizing Data.
679         *
680         * @param {string} device - indicates specified remote device.
681         * @param {string} table - indicates the target table.
682         * @param {RdbPredicates} predicates - the specified remote remote query condition by the instance object of {@link RdbPredicates}.
683         * @param {Array<string>} columns - the columns to remote query. If the value is empty array, the remote query applies to all columns.
684         * @param {AsyncCallback<ResultSet>} callback - the {@link ResultSet} object if the operation is successful.
685         * @throws {BusinessError} 401 - Parameter error.
686         * @throws {BusinessError} 14800000 - The inner error is occurred.
687         * @throws {BusinessError} 801 - Capability not supported.
688         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
689         * @since 9
690         */
691        remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>): void;
692
693        /**
694         * Queries remote data in the database based on specified conditions before Synchronizing Data.
695         *
696         * @param {string} device - indicates specified remote device.
697         * @param {string} table - indicates the target table.
698         * @param {RdbPredicates} predicates - the specified remote remote query condition by the instance object of {@link RdbPredicates}.
699         * @param {Array<string>} columns - the columns to remote query. If the value is empty array, the remote query applies to all columns.
700         * @returns {Promise<ResultSet>} the {@link ResultSet} object if the operation is successful.
701         * @throws {BusinessError} 401 - Parameter error.
702         * @throws {BusinessError} 14800000 - The inner error is occurred.
703         * @throws {BusinessError} 801 - Capability not supported.
704         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
705         * @since 9
706         */
707        remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array<string>): Promise<ResultSet>;
708
709        /**
710         * Registers an observer for the database. When data in the distributed database changes,
711         * the callback will be invoked.
712         *
713         * @param {string} event - indicates the event must be string 'dataChange'.
714         * @param {SubscribeType} type - indicates the subscription type, which is defined in {@link SubscribeType}.If its value is SUBSCRIBE_TYPE_REMOTE, ohos.permission.DISTRIBUTED_DATASYNC is required.
715         * @param {AsyncCallback<Array<string>>} observer - {Array<string>}: the observer of data change events in the distributed database.
716         * @throws {BusinessError} 401 - Parameter error.
717         * @throws {BusinessError} 801 - Capability not supported.
718         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
719         * @since 9
720         */
721        on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<string>>): void;
722
723        /**
724         * Remove specified observer of specified type from the database.
725         *
726         * @param {string} event - indicates the event must be string 'dataChange'.
727         * @param {SubscribeType} type - indicates the subscription type, which is defined in {@link SubscribeType}.If its value is SUBSCRIBE_TYPE_REMOTE, ohos.permission.DISTRIBUTED_DATASYNC is required.
728         * @param {AsyncCallback<Array<string>>} observer - {Array<string>}: the data change observer already registered.
729         * @throws {BusinessError} 401 - Parameter error.
730         * @throws {BusinessError} 14800000 - The inner error is occurred.
731         * @throws {BusinessError} 801 - Capability not supported.
732         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
733         * @since 9
734         */
735        off(event: 'dataChange', type: SubscribeType, observer: Callback<Array<string>>): void;
736    }
737
738    /**
739     * Manages relational database configurations.
740     *
741     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
742     * @since 9
743     */
744    class RdbPredicates {
745        /**
746         * A parameterized constructor used to create a RdbPredicates instance.
747         *
748         * @param {string} name - indicates the table name of the database.
749         * @throws {BusinessError} 401 - Parameter error.
750         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
751         * @since 9
752         */
753        constructor(name: string)
754
755        /**
756         * Specifies remote devices which connect to local device when syncing distributed database.
757         * When query database, this function should not be called.
758         *
759         * @param {Array<string>} devices - indicates specified remote devices.
760         * @returns {RdbPredicates} -  the {@link RdbPredicates} self.
761         * @throws {BusinessError} 401 - Parameter error.
762         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
763         * @since 9
764         */
765        inDevices(devices: Array<string>): RdbPredicates;
766
767        /**
768         * Specifies all remote devices which connect to local device when syncing distributed database.
769         * When query database, this function should not be called.
770         *
771         * @returns {RdbPredicates} - the {@link RdbPredicates} self.
772         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
773         * @since 9
774         */
775        inAllDevices(): RdbPredicates;
776
777        /**
778         * Configure the RdbPredicates to match the field whose data type is ValueType and value is equal
779         * to a specified value.
780         * This method is similar to = of the SQL statement.
781         *
782         * @param {string} field - indicates the column name in the database table.
783         * @param {ValueType} value - indicates the value to match with the {@link RdbPredicates}.
784         * @returns {RdbPredicates} - the {@link RdbPredicates} self.
785         * @throws {BusinessError} 401 - Parameter error.
786         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
787         * @since 9
788         */
789        equalTo(field: string, value: ValueType): RdbPredicates;
790
791        /**
792         * Configure the RdbPredicates to match the field whose data type is ValueType and value is not equal to
793         * a specified value.
794         * This method is similar to != of the SQL statement.
795         *
796         * @param {string} field - indicates the column name in the database table.
797         * @param {ValueType} value - indicates the value to match with the {@link RdbPredicates}.
798         * @returns {RdbPredicates} - the {@link RdbPredicates} self.
799         * @throws {BusinessError} 401 - Parameter error.
800         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
801         * @since 9
802         */
803        notEqualTo(field: string, value: ValueType): RdbPredicates;
804
805        /**
806         * Adds a left parenthesis to the RdbPredicates.
807         * This method is similar to ( of the SQL statement and needs to be used together with endWrap().
808         *
809         * @returns {RdbPredicates} - the {@link RdbPredicates} with the left parenthesis.
810         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
811         * @since 9
812         */
813        beginWrap(): RdbPredicates;
814
815        /**
816         * Adds a right parenthesis to the RdbPredicates.
817         * This method is similar to ) of the SQL statement and needs to be used together with beginWrap().
818         *
819         * @returns {RdbPredicates} - the {@link RdbPredicates} with the right parenthesis.
820         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
821         * @since 9
822         */
823        endWrap(): RdbPredicates;
824
825        /**
826         * Adds an or condition to the RdbPredicates.
827         * This method is similar to or of the SQL statement.
828         *
829         * @returns {RdbPredicates} - the {@link RdbPredicates} with the or condition.
830         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
831         * @since 9
832         */
833        or(): RdbPredicates;
834
835        /**
836         * Adds an and condition to the RdbPredicates.
837         * This method is similar to and of the SQL statement.
838         *
839         * @returns {RdbPredicates} - the {@link RdbPredicates} with the and condition.
840         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
841         * @since 9
842         */
843        and(): RdbPredicates;
844
845        /**
846         * Configure the RdbPredicates to match the field whose data type is string and value
847         * contains a specified value.
848         * This method is similar to contains of the SQL statement.
849         *
850         * @param {string} field - indicates the column name in the database table.
851         * @param {ValueType} value - indicates the value to match with the {@link RdbPredicates}.
852         * @returns {RdbPredicates} - the {@link RdbPredicates} self.
853         * @throws {BusinessError} 401 - Parameter error.
854         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
855         * @since 9
856         */
857        contains(field: string, value: string): RdbPredicates;
858
859        /**
860         * Configure the RdbPredicates to match the field whose data type is string and value starts
861         * with a specified string.
862         * This method is similar to value% of the SQL statement.
863         *
864         * @param {string} field - indicates the column name in the database table.
865         * @param {ValueType} value - indicates the value to match with the {@link RdbPredicates}.
866         * @returns {RdbPredicates} - the {@link RdbPredicates} self.
867         * @throws {BusinessError} 401 - Parameter error.
868         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
869         * @since 9
870         */
871        beginsWith(field: string, value: string): RdbPredicates;
872
873        /**
874         * Configure the RdbPredicates to match the field whose data type is string and value
875         * ends with a specified string.
876         * This method is similar to %value of the SQL statement.
877         *
878         * @param {string} field - indicates the column name in the database table.
879         * @param {ValueType} value - indicates the value to match with the {@link RdbPredicates}.
880         * @returns {RdbPredicates} - the {@link RdbPredicates} self.
881         * @throws {BusinessError} 401 - Parameter error.
882         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
883         * @since 9
884         */
885        endsWith(field: string, value: string): RdbPredicates;
886
887        /**
888         * Configure the RdbPredicates to match the fields whose value is null.
889         * This method is similar to is null of the SQL statement.
890         *
891         * @param {string} field - indicates the column name in the database table.
892         * @returns {RdbPredicates} - the {@link RdbPredicates} self.
893         * @throws {BusinessError} 401 - Parameter error.
894         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
895         * @since 9
896         */
897        isNull(field: string): RdbPredicates;
898
899        /**
900         * Configure the RdbPredicates to match the specified fields whose value is not null.
901         * This method is similar to is not null of the SQL statement.
902         *
903         * @param {string} field - indicates the column name in the database table.
904         * @returns {RdbPredicates} - the {@link RdbPredicates} self.
905         * @throws {BusinessError} 401 - Parameter error.
906         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
907         * @since 9
908         */
909        isNotNull(field: string): RdbPredicates;
910
911        /**
912         * Configure the RdbPredicates to match the fields whose data type is string and value is
913         * similar to a specified string.
914         * This method is similar to like of the SQL statement.
915         *
916         * @param {string} field - indicates the column name in the database table.
917         * @param {ValueType} value - indicates the value to match with the {@link RdbPredicates}.
918         * @returns {RdbPredicates} - the {@link RdbPredicates} that match the specified field.
919         * @throws {BusinessError} 401 - Parameter error.
920         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
921         * @since 9
922         */
923        like(field: string, value: string): RdbPredicates;
924
925        /**
926         * Configure RdbPredicates to match the specified field whose data type is string and the value contains
927         * a wildcard.
928         * Different from like, the input parameters of this method are case-sensitive.
929         *
930         * @param {string} field - indicates the column name in the database table.
931         * @param {ValueType} value - indicates the value to match with the {@link RdbPredicates}.
932         * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}.
933         * @throws {BusinessError} 401 - Parameter error.
934         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
935         * @since 9
936         */
937        glob(field: string, value: string): RdbPredicates;
938
939        /**
940         * Configure RdbPredicates to match the specified field whose value is within a given range.
941         *
942         * @param {string} field - indicates the column name.
943         * @param {ValueType} low - indicates the minimum value.
944         * @param {ValueType} high - indicates the maximum value.
945         * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}.
946         * @throws {BusinessError} 401 - Parameter error.
947         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
948         * @since 9
949         */
950        between(field: string, low: ValueType, high: ValueType): RdbPredicates;
951
952        /**
953         * Configure RdbPredicates to match the specified field whose value is out of a given range.
954         *
955         * @param {string} field - indicates the column name in the database table.
956         * @param {ValueType} low - indicates the minimum value.
957         * @param {ValueType} high - indicates the maximum value.
958         * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}.
959         * @throws {BusinessError} 401 - Parameter error.
960         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
961         * @since 9
962         */
963        notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates;
964
965        /**
966         * Restricts the value of the field to be greater than the specified value.
967         *
968         * @param {string} field - indicates the column name in the database table.
969         * @param {ValueType} value - indicates the value to match with the {@link RdbPredicates}.
970         * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}.
971         * @throws {BusinessError} 401 - Parameter error.
972         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
973         * @since 9
974         */
975        greaterThan(field: string, value: ValueType): RdbPredicates;
976
977        /**
978         * Restricts the value of the field to be smaller than the specified value.
979         *
980         * @param {string} field - indicates the column name in the database table.
981         * @param {ValueType} value - indicates the value to match with the {@link RdbPredicates}.
982         * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}.
983         * @throws {BusinessError} 401 - Parameter error.
984         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
985         * @since 9
986         */
987        lessThan(field: string, value: ValueType): RdbPredicates;
988
989        /**
990         * Restricts the value of the field to be greater than or equal to the specified value.
991         *
992         * @param {string} field - indicates the column name in the database table.
993         * @param {ValueType} value - indicates the value to match with the {@link RdbPredicates}.
994         * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}.
995         * @throws {BusinessError} 401 - Parameter error.
996         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
997         * @since 9
998         */
999        greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates;
1000
1001        /**
1002         * Restricts the value of the field to be smaller than or equal to the specified value.
1003         *
1004         * @param {string} field - indicates the column name in the database table.
1005         * @param {ValueType} value - indicates the value to match with the {@link RdbPredicates}.
1006         * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}.
1007         * @throws {BusinessError} 401 - Parameter error.
1008         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1009         * @since 9
1010         */
1011        lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates;
1012
1013        /**
1014         * Restricts the ascending order of the return list. When there are several orders,
1015         * the one close to the head has the highest priority.
1016         *
1017         * @param {string} field - indicates the column name for sorting the return list.
1018         * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}.
1019         * @throws {BusinessError} 401 - Parameter error.
1020         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1021         * @since 9
1022         */
1023        orderByAsc(field: string): RdbPredicates;
1024
1025        /**
1026         * Restricts the descending order of the return list. When there are several orders,
1027         * the one close to the head has the highest priority.
1028         *
1029         * @param {string} field - indicates the column name for sorting the return list.
1030         * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}.
1031         * @throws {BusinessError} 401 - Parameter error.
1032         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1033         * @since 9
1034         */
1035        orderByDesc(field: string): RdbPredicates;
1036
1037        /**
1038         * Restricts each row of the query result to be unique.
1039         *
1040         * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}.
1041         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1042         * @since 9
1043         */
1044        distinct(): RdbPredicates;
1045
1046        /**
1047         * Restricts the max number of return records.
1048         *
1049         * @param {number} value - indicates the max length of the return list.
1050         * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}.
1051         * @throws {BusinessError} 401 - Parameter error.
1052         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1053         * @since 9
1054         */
1055        limitAs(value: number): RdbPredicates;
1056
1057        /**
1058         * Configure RdbPredicates to specify the start position of the returned result.
1059         * Use this method together with limit(number).
1060         *
1061         * @param {number} rowOffset - indicates the start position of the returned result. The value is a positive integer.
1062         * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}.
1063         * @throws {BusinessError} 401 - Parameter error.
1064         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1065         * @since 9
1066         */
1067        offsetAs(rowOffset: number): RdbPredicates;
1068
1069        /**
1070         * Configure RdbPredicates to group query results by specified columns.
1071         *
1072         * @param {Array<string>} fields - indicates the specified columns by which query results are grouped.
1073         * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}.
1074         * @throws {BusinessError} 401 - Parameter error.
1075         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1076         * @since 9
1077         */
1078        groupBy(fields: Array<string>): RdbPredicates;
1079
1080        /**
1081         * Configure RdbPredicates to specify the index column.
1082         * Before using this method, you need to create an index column.
1083         *
1084         * @param {string} field - indicates the name of the index column.
1085         * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}.
1086         * @throws {BusinessError} 401 - Parameter error.
1087         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1088         * @since 9
1089         */
1090        indexedBy(field: string): RdbPredicates;
1091
1092        /**
1093         * Configure RdbPredicates to match the specified field whose data type is ValueType array and values
1094         * are within a given range.
1095         *
1096         * @param {string} field - indicates the column name in the database table.
1097         * @param {Array<ValueType>} value - indicates the values to match with {@link RdbPredicates}.
1098         * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}.
1099         * @throws {BusinessError} 401 - Parameter error.
1100         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1101         * @since 9
1102         */
1103        in(field: string, value: Array<ValueType>): RdbPredicates;
1104
1105        /**
1106         * Configure RdbPredicates to match the specified field whose data type is ValueType array and values
1107         * are out of a given range.
1108         *
1109         * @param {string} field - indicates the column name in the database table.
1110         * @param {Array<ValueType>} value - indicates the values to match with {@link RdbPredicates}.
1111         * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}.
1112         * @throws {BusinessError} 401 - Parameter error.
1113         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1114         * @since 9
1115         */
1116        notIn(field: string, value: Array<ValueType>): RdbPredicates;
1117    }
1118
1119    /**
1120     * Provides methods for accessing a database result set generated by querying the database.
1121     *
1122     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1123     * @since 9
1124     */
1125    interface ResultSet {
1126
1127        /**
1128         * Obtains the names of all columns in a result set.
1129         * The column names are returned as a string array, in which the strings are in the same order
1130         * as the columns in the result set.
1131         *
1132         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1133         * @since 9
1134         */
1135        columnNames: Array<string>;
1136
1137        /**
1138         * Obtains the number of columns in the result set.
1139         * The returned number is equal to the length of the string array returned by the
1140         * columnNames method.
1141         *
1142         * @since 9
1143         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1144         */
1145        columnCount: number;
1146
1147        /**
1148         * Obtains the number of rows in the result set.
1149         *
1150         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1151         * @since 9
1152         */
1153        rowCount: number;
1154
1155        /**
1156         * Obtains the current index of the result set.
1157         * The result set index starts from 0.
1158         *
1159         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1160         * @since 9
1161         */
1162        rowIndex: number;
1163
1164        /**
1165         * Checks whether the cursor is positioned at the first row.
1166         *
1167         * @since 9
1168         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1169         */
1170        isAtFirstRow: boolean;
1171
1172        /**
1173         * Checks whether the cursor is positioned at the last row.
1174         *
1175         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1176         * @since 9
1177         */
1178        isAtLastRow: boolean;
1179
1180        /**
1181         * Checks whether the cursor is positioned after the last row.
1182         *
1183         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1184         * @since 9
1185         */
1186        isEnded: boolean;
1187
1188        /**
1189         * Checks whether the cursor is positioned before the first row.
1190         *
1191         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1192         * @since 9
1193         */
1194        isStarted: boolean;
1195
1196        /**
1197         * Checks whether the current result set is closed.
1198         *
1199         * If the result set is closed by calling the close method, true will be returned.
1200         *
1201         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1202         * @since 9
1203         */
1204        isClosed: boolean;
1205
1206        /**
1207         * Obtains the column index based on the specified column name.
1208         * The column name is passed as an input parameter.
1209         *
1210         * @param {string} columnName - indicates the name of the specified column in the result set.
1211         * @returns {number} the index of the specified column.
1212         * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible.
1213         * @throws {BusinessError} 401 - Parameter error.
1214         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1215         * @since 9
1216         */
1217        getColumnIndex(columnName: string): number;
1218
1219        /**
1220         * Obtains the column name based on the specified column index.
1221         * The column index is passed as an input parameter.
1222         *
1223         * @param {number} columnIndex - indicates the index of the specified column in the result set.
1224         * @returns {string} the name of the specified column.
1225         * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible.
1226         * @throws {BusinessError} 401 - Parameter error.
1227         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1228         * @since 9
1229         */
1230        getColumnName(columnIndex: number): string;
1231
1232        /**
1233         * Go to the specified row of the result set forwards or backwards by an offset relative to its current position.
1234         * A positive offset indicates moving backwards, and a negative offset indicates moving forwards.
1235         *
1236         * @param {number} offset - indicates the offset relative to the current position.
1237         * @returns {string} true if the result set is moved successfully and does not go beyond the range;
1238         *                   returns false otherwise.
1239         * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid.
1240         * @throws {BusinessError} 401 - Parameter error.
1241         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1242         * @since 9
1243         */
1244        goTo(offset: number): boolean;
1245
1246        /**
1247         * Go to the specified row of the result set.
1248         *
1249         * @param {number} position - indicates the index of the specified row, which starts from 0.
1250         * @returns {boolean} true if the result set is moved successfully; returns false otherwise.
1251         * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid.
1252         * @throws {BusinessError} 401 - Parameter error.
1253         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1254         * @since 9
1255         */
1256        goToRow(position: number): boolean;
1257
1258        /**
1259         * Go to the first row of the result set.
1260         *
1261         * @returns {boolean} true if the result set is moved successfully;
1262         *                    returns false otherwise, for example, if the result set is empty.
1263         * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid.
1264         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1265         * @since 9
1266         */
1267        goToFirstRow(): boolean;
1268
1269        /**
1270         * Go to the last row of the result set.
1271         *
1272         * @returns {boolean} true if the result set is moved successfully;
1273         *                    returns false otherwise, for example, if the result set is empty.
1274         * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid.
1275         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1276         * @since 9
1277         */
1278        goToLastRow(): boolean;
1279
1280        /**
1281         * Go to the next row of the result set.
1282         *
1283         * @returns {boolean} true if the result set is moved successfully;
1284         *                    returns false otherwise, for example, if the result set is already in the last row.
1285         * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid.
1286         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1287         * @since 9
1288         */
1289        goToNextRow(): boolean;
1290
1291        /**
1292         * Go to the previous row of the result set.
1293         *
1294         * @returns {boolean} true if the result set is moved successfully;
1295         *                    returns false otherwise, for example, if the result set is already in the first row.
1296         * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid.
1297         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1298         * @since 9
1299         */
1300        goToPreviousRow(): boolean;
1301
1302        /**
1303         * Obtains the value of the specified column in the current row as a byte array.
1304         * The implementation class determines whether to throw an exception if the value of the specified column
1305         * in the current row is null or the specified column is not of the Blob type.
1306         *
1307         * @param {number} columnIndex - indicates the specified column index, which starts from 0.
1308         * @returns {Uint8Array} the value of the specified column as a byte array.
1309         * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible.
1310         * @throws {BusinessError} 401 - Parameter error.
1311         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1312         * @since 9
1313         */
1314        getBlob(columnIndex: number): Uint8Array;
1315
1316        /**
1317         * Obtains the value of the specified column in the current row as string.
1318         * The implementation class determines whether to throw an exception if the value of the specified column
1319         * in the current row is null or the specified column is not of the string type.
1320         *
1321         * @param {number} columnIndex - indicates the specified column index, which starts from 0.
1322         * @returns {string} the value of the specified column as a string.
1323         * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible.
1324         * @throws {BusinessError} 401 - Parameter error.
1325         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1326         * @since 9
1327         */
1328        getString(columnIndex: number): string;
1329
1330        /**
1331         * Obtains the value of the specified column in the current row as long.
1332         * The implementation class determines whether to throw an exception if the value of the specified column
1333         * in the current row is null, the specified column is not of the integer type.
1334         *
1335         * @param {number} columnIndex - indicates the specified column index, which starts from 0.
1336         * @returns {number} the value of the specified column as a long.
1337         * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible.
1338         * @throws {BusinessError} 401 - Parameter error.
1339         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1340         * @since 9
1341         */
1342        getLong(columnIndex: number): number;
1343
1344        /**
1345         * Obtains the value of the specified column in the current row as double.
1346         * The implementation class determines whether to throw an exception if the value of the specified column
1347         * in the current row is null, the specified column is not of the double type.
1348         *
1349         * @param {number} columnIndex - indicates the specified column index, which starts from 0.
1350         * @returns {number} the value of the specified column as a double.
1351         * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible.
1352         * @throws {BusinessError} 401 - Parameter error.
1353         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1354         * @since 9
1355         */
1356        getDouble(columnIndex: number): number;
1357
1358        /**
1359         * Checks whether the value of the specified column in the current row is null.
1360         *
1361         * @param {number} columnIndex - indicates the specified column index, which starts from 0.
1362         * @returns {boolean} true if the value of the specified column in the current row is null;
1363         *                    returns false otherwise.
1364         * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible.
1365         * @throws {BusinessError} 401 - Parameter error.
1366         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1367         * @since 9
1368         */
1369        isColumnNull(columnIndex: number): boolean;
1370
1371        /**
1372         * Closes the result set.
1373         * Calling this method on the result set will release all of its resources and makes it ineffective.
1374         *
1375         * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid.
1376         * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
1377         * @since 9
1378         */
1379        close(): void;
1380    }
1381}
1382
1383export default relationalStore;