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