1/* 2 * Copyright (c) 2021 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 16/** 17 * @file 18 * @kit ArkData 19 */ 20 21import { AsyncCallback, Callback } from './@ohos.base'; 22import { ResultSet as _ResultSet } from './data/rdb/resultSet'; 23import Context from './application/BaseContext'; 24 25/** 26 * Provides methods for rdbStore create and delete. 27 * 28 * @namespace rdb 29 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 30 * @since 7 31 * @deprecated since 9 32 * @useinstead ohos.data.relationalStore 33 */ 34declare namespace rdb { 35 /** 36 * Obtains an RDB store. 37 * You can set parameters of the RDB store as required. In general, this method is recommended 38 * to obtain a rdb store. 39 * 40 * @param { Context } context - Indicates the context of application or capability. 41 * @param { StoreConfig } config - Indicates the {@link StoreConfig} configuration of the database related to this RDB store. 42 * @param { number } version - Indicates the database version for upgrade or downgrade. 43 * @param { AsyncCallback<RdbStore> } callback - The RDB store {@link RdbStore}. 44 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 45 * @since 7 46 * @deprecated since 9 47 * @useinstead ohos.data.relationalStore.getRdbStore 48 */ 49 function getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void; 50 51 /** 52 * Obtains an RDB store. 53 * You can set parameters of the RDB store as required. In general, this method is recommended 54 * to obtain a rdb store. 55 * 56 * @param { Context } context - Indicates the context of application or capability. 57 * @param { StoreConfig } config - Indicates the {@link StoreConfig} configuration of the database related to this RDB store. 58 * @param { number } version - Indicates the database version for upgrade or downgrade. 59 * @returns { Promise<RdbStore> } The RDB store {@link RdbStore}. 60 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 61 * @since 7 62 * @deprecated since 9 63 * @useinstead ohos.data.relationalStore.getRdbStore 64 */ 65 function getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore>; 66 67 /** 68 * Deletes the database with a specified name. 69 * 70 * @param { Context } context - Indicates the context of application or capability. 71 * @param { string } name - Indicates the database name. 72 * @param { AsyncCallback<void> } callback - The callback of deleteRdbStore. 73 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 74 * @since 7 75 * @deprecated since 9 76 * @useinstead ohos.data.relationalStore.deleteRdbStore 77 */ 78 function deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void>): void; 79 /** 80 * Deletes the database with a specified name. 81 * 82 * @param { Context } context - Indicates the context of application or capability. 83 * @param { string } name - Indicates the database name. 84 * @returns { Promise<void> } The promise returned by the function. 85 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 86 * @since 7 87 * @deprecated since 9 88 * @useinstead ohos.data.relationalStore.deleteRdbStore 89 */ 90 function deleteRdbStore(context: Context, name: string): Promise<void>; 91 92 /** 93 * Indicates the database synchronization mode. 94 * 95 * @enum { number } 96 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 97 * @since 8 98 * @deprecated since 9 99 * @useinstead ohos.data.relationalStore.SyncMode 100 */ 101 enum SyncMode { 102 /** 103 * Indicates the data is pushed to remote device from local device. 104 * 105 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 106 * @since 8 107 * @deprecated since 9 108 * @useinstead ohos.data.relationalStore.SyncMode.SYNC_MODE_PUSH 109 */ 110 SYNC_MODE_PUSH = 0, 111 112 /** 113 * Indicates the data is pulled from remote device to local device. 114 * 115 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 116 * @since 8 117 * @deprecated since 9 118 * @useinstead ohos.data.relationalStore.SyncMode.SYNC_MODE_PULL 119 */ 120 SYNC_MODE_PULL = 1 121 } 122 123 /** 124 * Describes the subscription type. 125 * 126 * @permission ohos.permission.DISTRIBUTED_DATASYNC 127 * @enum { number } 128 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 129 * @since 8 130 * @deprecated since 9 131 * @useinstead ohos.data.relationalStore.SubscribeType 132 */ 133 enum SubscribeType { 134 /** 135 * Subscription to remote data changes 136 * 137 * @permission ohos.permission.DISTRIBUTED_DATASYNC 138 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 139 * @since 8 140 * @deprecated since 9 141 * @useinstead ohos.data.relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE 142 */ 143 SUBSCRIBE_TYPE_REMOTE = 0 144 } 145 146 /** 147 * Provides methods for managing the relational database (RDB). 148 * This class provides methods for creating, querying, updating, and deleting RDBs. 149 * 150 * @interface RdbStore 151 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 152 * @since 7 153 * @deprecated since 9 154 * @useinstead ohos.data.relationalStore.RdbStore 155 */ 156 interface RdbStore { 157 /** 158 * Inserts a row of data into the target table. 159 * 160 * @param { string } table - Indicates the row of data to be inserted into the table. 161 * @param { ValuesBucket } values - Indicates the row of data {@link ValuesBucket} to be inserted into the table. 162 * @param { AsyncCallback<number> } callback - The row ID if the operation is successful. returns -1 otherwise. 163 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 164 * @since 7 165 * @deprecated since 9 166 * @useinstead ohos.data.relationalStore.RdbStore.insert 167 */ 168 insert(table: string, values: ValuesBucket, callback: AsyncCallback<number>): void; 169 170 /** 171 * Inserts a row of data into the target table. 172 * 173 * @param { string } table - Indicates the row of data to be inserted into the table. 174 * @param { ValuesBucket } values - Indicates the row of data {@link ValuesBucket} to be inserted into the table. 175 * @returns { Promise<number> } Return the row ID if the operation is successful. return -1 otherwise. 176 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 177 * @since 7 178 * @deprecated since 9 179 * @useinstead ohos.data.relationalStore.RdbStore.insert 180 */ 181 insert(table: string, values: ValuesBucket): Promise<number>; 182 183 /** 184 * Inserts a batch of data into the target table. 185 * 186 * @param { string } table - Indicates the target table. 187 * @param { Array<ValuesBucket> } values - Indicates the rows of data {@link ValuesBucket} to be inserted into the table. 188 * @param { AsyncCallback<number> } callback - The number of values that were inserted if the operation is successful. returns -1 otherwise. 189 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 190 * @since 7 191 * @deprecated since 9 192 * @useinstead ohos.data.relationalStore.RdbStore.batchInsert 193 */ 194 batchInsert(table: string, values: Array<ValuesBucket>, callback: AsyncCallback<number>): void; 195 196 /** 197 * Inserts a batch of data into the target table. 198 * 199 * @param { string } table - Indicates the target table. 200 * @param { Array<ValuesBucket> } values - Indicates the rows of data {@link ValuesBucket} to be inserted into the table. 201 * @returns { Promise<number> } Return the number of values that were inserted if the operation is successful. returns -1 otherwise. 202 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 203 * @since 7 204 * @deprecated since 9 205 * @useinstead ohos.data.relationalStore.RdbStore.batchInsert 206 */ 207 batchInsert(table: string, values: Array<ValuesBucket>): Promise<number>; 208 209 /** 210 * Updates data in the database based on a a specified instance object of RdbPredicates. 211 * 212 * @param { ValuesBucket } values - Indicates Indicates the row of data to be updated in the database. 213 * The key-value pairs are associated with column names of the database table. 214 * @param { RdbPredicates } predicates - Indicates the specified update condition by the instance object of {@link RdbPredicates}. 215 * @param { AsyncCallback<number> } callback - The number of affected rows. 216 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 217 * @since 7 218 * @deprecated since 9 219 * @useinstead ohos.data.relationalStore.RdbStore.update 220 */ 221 update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback<number>): void; 222 223 /** 224 * Updates data in the database based on a a specified instance object of RdbPredicates. 225 * 226 * @param { ValuesBucket } values - Indicates Indicates the row of data to be updated in the database. 227 * The key-value pairs are associated with column names of the database table. 228 * @param { RdbPredicates } predicates - Indicates the specified update condition by the instance object of {@link RdbPredicates}. 229 * @returns { Promise<number> } Return the number of affected rows. 230 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 231 * @since 7 232 * @deprecated since 9 233 * @useinstead ohos.data.relationalStore.RdbStore.update 234 */ 235 update(values: ValuesBucket, predicates: RdbPredicates): Promise<number>; 236 237 /** 238 * Deletes data from the database based on a specified instance object of RdbPredicates. 239 * 240 * @param { RdbPredicates } predicates - The specified delete condition by the instance object of {@link RdbPredicates}. 241 * @param { AsyncCallback<number> } callback - The number of affected rows. 242 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 243 * @since 7 244 * @deprecated since 9 245 * @useinstead ohos.data.relationalStore.RdbStore.delete 246 */ 247 delete(predicates: RdbPredicates, callback: AsyncCallback<number>): void; 248 249 /** 250 * Deletes data from the database based on a specified instance object of RdbPredicates. 251 * 252 * @param { RdbPredicates } predicates - The specified delete condition by the instance object of {@link RdbPredicates}. 253 * @returns { Promise<number> } Return the number of affected rows. 254 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 255 * @since 7 256 * @deprecated since 9 257 * @useinstead ohos.data.relationalStore.RdbStore.delete 258 */ 259 delete(predicates: RdbPredicates): Promise<number>; 260 261 /** 262 * Queries data in the database based on specified conditions. 263 * 264 * @param { RdbPredicates } predicates - The specified query condition by the instance object of {@link RdbPredicates}. 265 * @param { Array<string> } columns - The columns to query. If the value is empty array, the query applies to all columns. 266 * @param { AsyncCallback<ResultSet> } callback - The {@link ResultSet} object if the operation is successful. 267 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 268 * @since 7 269 * @deprecated since 9 270 * @useinstead ohos.data.relationalStore.RdbStore.query 271 */ 272 query(predicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>): void; 273 274 /** 275 * Queries data in the database based on specified conditions. 276 * 277 * @param { RdbPredicates } predicates - The specified query condition by the instance object of {@link RdbPredicates}. 278 * @param { Array<string> } columns - The columns to query. If the value is null, the query applies to all columns. 279 * @returns { Promise<ResultSet> } Return the {@link ResultSet} object if the operation is successful. 280 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 281 * @since 7 282 * @deprecated since 9 283 * @useinstead ohos.data.relationalStore.RdbStore.query 284 */ 285 query(predicates: RdbPredicates, columns?: Array<string>): Promise<ResultSet>; 286 287 /** 288 * Queries data in the database based on SQL statement. 289 * 290 * @param { string } sql - Indicates the SQL statement to execute. 291 * @param { Array<ValueType> } bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. 292 * @param { AsyncCallback<ResultSet> } callback 293 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 294 * @since 8 295 * @deprecated since 9 296 * @useinstead ohos.data.relationalStore.RdbStore.querySql 297 */ 298 querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<ResultSet>): void; 299 300 /** 301 * Queries data in the database based on SQL statement. 302 * 303 * @param { string } sql - Indicates the SQL statement to execute. 304 * @param { Array<ValueType> } bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. 305 * @returns { Promise<ResultSet> } Return the {@link ResultSet} object if the operation is successful. 306 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 307 * @since 8 308 * @deprecated since 9 309 * @useinstead ohos.data.relationalStore.RdbStore.querySql 310 */ 311 querySql(sql: string, bindArgs?: Array<ValueType>): Promise<ResultSet>; 312 313 /** 314 * Executes an SQL statement that contains specified parameters but returns no value. 315 * 316 * @param { string } sql - Indicates the SQL statement to execute. 317 * @param { Array<ValueType> } bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. 318 * @param { AsyncCallback<void> } callback - The callback of executeSql. 319 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 320 * @since 8 321 * @deprecated since 9 322 * @useinstead ohos.data.relationalStore.RdbStore.executeSql 323 */ 324 executeSql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<void>): void; 325 326 /** 327 * Executes an SQL statement that contains specified parameters but returns no value. 328 * 329 * @param { string } sql - Indicates the SQL statement to execute. 330 * @param { Array<ValueType> } bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. 331 * @returns { Promise<void> } The promise returned by the function. 332 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 333 * @since 8 334 * @deprecated since 9 335 * @useinstead ohos.data.relationalStore.RdbStore.executeSql 336 */ 337 executeSql(sql: string, bindArgs?: Array<ValueType>): Promise<void>; 338 339 /** 340 * Begin Transaction before execute your sql. 341 * 342 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 343 * @since 8 344 * @deprecated since 9 345 * @useinstead ohos.data.relationalStore.RdbStore.beginTransaction 346 */ 347 beginTransaction(): void; 348 349 /** 350 * Commit the the sql you have executed. 351 * 352 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 353 * @since 8 354 * @deprecated since 9 355 * @useinstead ohos.data.relationalStore.RdbStore.commit 356 */ 357 commit(): void; 358 359 /** 360 * Roll back the sql you have already executed. 361 * 362 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 363 * @since 8 364 * @deprecated since 9 365 * @useinstead ohos.data.relationalStore.RdbStore.rollBack 366 */ 367 rollBack(): void; 368 369 /** 370 * Set table to be distributed table. 371 * 372 * @permission ohos.permission.DISTRIBUTED_DATASYNC 373 * @param { Array<string> } tables - Indicates the tables name you want to set. 374 * @param { AsyncCallback<void> } callback - The callback of setDistributedTables. 375 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 376 * @since 8 377 * @deprecated since 9 378 * @useinstead ohos.data.relationalStore.RdbStore.setDistributedTables 379 */ 380 setDistributedTables(tables: Array<string>, callback: AsyncCallback<void>): void; 381 382 /** 383 * Set table to be distributed table. 384 * 385 * @permission ohos.permission.DISTRIBUTED_DATASYNC 386 * @param { Array<string> } tables - Indicates the tables name you want to set. 387 * @returns { Promise<void> } The promise returned by the function. 388 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 389 * @since 8 390 * @deprecated since 9 391 * @useinstead ohos.data.relationalStore.RdbStore.setDistributedTables 392 */ 393 setDistributedTables(tables: Array<string>): Promise<void>; 394 395 /** 396 * Obtain distributed table name of specified remote device according to local table name. 397 * When query remote device database, distributed table name is needed. 398 * 399 * @permission ohos.permission.DISTRIBUTED_DATASYNC 400 * @param { string } device - Indicates the remote device. 401 * @param { string } table - {string}: The distributed table name. 402 * @param { AsyncCallback<string> } callback 403 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 404 * @since 8 405 * @deprecated since 9 406 * @useinstead ohos.data.relationalStore.RdbStore.obtainDistributedTableName 407 */ 408 obtainDistributedTableName(device: string, table: string, callback: AsyncCallback<string>): void; 409 410 /** 411 * Obtain distributed table name of specified remote device according to local table name. 412 * When query remote device database, distributed table name is needed. 413 * 414 * @permission ohos.permission.DISTRIBUTED_DATASYNC 415 * @param { string } device - Indicates the remote device. 416 * @param { string } table 417 * @returns { Promise<string> } {string}: The distributed table name. 418 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 419 * @since 8 420 * @deprecated since 9 421 * @useinstead ohos.data.relationalStore.RdbStore.obtainDistributedTableName 422 */ 423 obtainDistributedTableName(device: string, table: string): Promise<string>; 424 425 /** 426 * Sync data between devices. 427 * 428 * @permission ohos.permission.DISTRIBUTED_DATASYNC 429 * @param { SyncMode } mode - Indicates the remote device. 430 * @param { RdbPredicates } predicates - {Array<[string, number]>}: Devices sync status array, {string}: device id, {number}: device sync status. 431 * @param { AsyncCallback<Array<[string, number]>> } callback 432 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 433 * @since 8 434 * @deprecated since 9 435 * @useinstead ohos.data.relationalStore.RdbStore.sync 436 */ 437 sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array<[string, number]>>): void; 438 439 /** 440 * Sync data between devices. 441 * 442 * @permission ohos.permission.DISTRIBUTED_DATASYNC 443 * @param { SyncMode } mode - Indicates the remote device. 444 * @param { RdbPredicates } predicates 445 * @returns { Promise<Array<[string, number]>> } {Array<[string, number]>}: Devices sync status array, {string}: device id, {number}: device sync status. 446 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 447 * @since 8 448 * @deprecated since 9 449 * @useinstead ohos.data.relationalStore.RdbStore.sync 450 */ 451 sync(mode: SyncMode, predicates: RdbPredicates): Promise<Array<[string, number]>>; 452 453 /** 454 * Registers an observer for the database. When data in the distributed database changes, 455 * the callback will be invoked. 456 * 457 * @param { 'dataChange' } event - Indicates the event must be string 'dataChange'. 458 * @param { SubscribeType } type - Indicates the subscription type, which is defined in {@link SubscribeType}. 459 * If its value is SUBSCRIBE_TYPE_REMOTE, ohos.permission.DISTRIBUTED_DATASYNC is required. 460 * @param { Callback<Array<string>> } observer - {Array<string>}: The observer of data change events in the distributed database. 461 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 462 * @since 8 463 * @deprecated since 9 464 * @useinstead ohos.data.relationalStore.RdbStore.on 465 */ 466 on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<string>>): void; 467 468 /** 469 * Remove specified observer of specified type from the database. 470 * 471 * @param { 'dataChange' } event - Indicates the event must be string 'dataChange'. 472 * @param { SubscribeType } type - Indicates the subscription type, which is defined in {@link SubscribeType}. 473 * If its value is SUBSCRIBE_TYPE_REMOTE, ohos.permission.DISTRIBUTED_DATASYNC is required. 474 * @param { Callback<Array<string>> } observer - {Array<string>}: The data change observer already registered. 475 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 476 * @since 8 477 * @deprecated since 9 478 * @useinstead ohos.data.relationalStore.RdbStore.off 479 */ 480 off(event: 'dataChange', type: SubscribeType, observer: Callback<Array<string>>): void; 481 } 482 483 /** 484 * Indicates possible value types 485 * 486 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 487 * @since 7 488 * @deprecated since 9 489 * @useinstead ohos.data.relationalStore.ValueType 490 */ 491 type ValueType = number | string | boolean; 492 493 /** 494 * Values in buckets are stored in key-value pairs 495 * 496 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 497 * @since 7 498 * @deprecated since 9 499 * @useinstead ohos.data.relationalStore.ValuesBucket 500 */ 501 type ValuesBucket = { [key: string]: ValueType | Uint8Array | null }; 502 503 /** 504 * Manages relational database configurations. 505 * 506 * @interface StoreConfig 507 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 508 * @since 7 509 * @deprecated since 9 510 * @useinstead ohos.data.relationalStore.StoreConfig 511 */ 512 interface StoreConfig { 513 name: string; 514 } 515 516 /** 517 * Manages relational database configurations. 518 * 519 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 520 * @since 7 521 * @deprecated since 9 522 * @useinstead ohos.data.relationalStore.RdbPredicates 523 */ 524 class RdbPredicates { 525 /** 526 * A parameterized constructor used to create an RdbPredicates instance. 527 * 528 * @param { string } name - Indicates the table name of the database. 529 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 530 * @since 7 531 * @deprecated since 9 532 * @useinstead ohos.data.relationalStore.RdbPredicates.constructor 533 */ 534 constructor(name: string); 535 536 /** 537 * Sync data between devices. 538 * When query database, this function should not be called. 539 * 540 * @param { Array<string> } devices - Indicates specified remote devices. 541 * @returns { RdbPredicates } - The {@link RdbPredicates} self. 542 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 543 * @since 8 544 * @deprecated since 9 545 * @useinstead ohos.data.relationalStore.RdbPredicates.inDevices 546 */ 547 inDevices(devices: Array<string>): RdbPredicates; 548 549 /** 550 * Specify all remote devices which connect to local device when syncing distributed database. 551 * When query database, this function should not be called. 552 * 553 * @returns { RdbPredicates } - The {@link RdbPredicates} self. 554 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 555 * @since 8 556 * @deprecated since 9 557 * @useinstead ohos.data.relationalStore.RdbPredicates.inAllDevices 558 */ 559 inAllDevices(): RdbPredicates; 560 561 /** 562 * Configure the RdbPredicates to match the field whose data type is ValueType and value is equal 563 * to a specified value. 564 * This method is similar to = of the SQL statement. 565 * 566 * @param { string } field - Indicates the column name in the database table. 567 * @param { ValueType } value - Indicates the value to match with the {@link RdbPredicates}. 568 * @returns { RdbPredicates } - The {@link RdbPredicates} self. 569 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 570 * @since 7 571 * @deprecated since 9 572 * @useinstead ohos.data.relationalStore.RdbPredicates.equalTo 573 */ 574 equalTo(field: string, value: ValueType): RdbPredicates; 575 576 /** 577 * Configure the RdbPredicates to match the field whose data type is ValueType and value is not equal to 578 * a specified value. 579 * This method is similar to != of the SQL statement. 580 * 581 * @param { string } field - Indicates the column name in the database table. 582 * @param { ValueType } value - Indicates the value to match with the {@link RdbPredicates}. 583 * @returns { RdbPredicates } - The {@link RdbPredicates} self. 584 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 585 * @since 7 586 * @deprecated since 9 587 * @useinstead ohos.data.relationalStore.RdbPredicates.notEqualTo 588 */ 589 notEqualTo(field: string, value: ValueType): RdbPredicates; 590 591 /** 592 * Adds a left parenthesis to the RdbPredicates. 593 * This method is similar to ( of the SQL statement and needs to be used together with endWrap(). 594 * 595 * @returns { RdbPredicates } - The {@link RdbPredicates} with the left parenthesis. 596 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 597 * @since 7 598 * @deprecated since 9 599 * @useinstead ohos.data.relationalStore.RdbPredicates.beginWrap 600 */ 601 beginWrap(): RdbPredicates; 602 603 /** 604 * Adds a right parenthesis to the RdbPredicates. 605 * This method is similar to ) of the SQL statement and needs to be used together 606 * with beginWrap(). 607 * 608 * @returns { RdbPredicates } - The {@link RdbPredicates} with the right parenthesis. 609 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 610 * @since 7 611 * @deprecated since 9 612 * @useinstead ohos.data.relationalStore.RdbPredicates.endWrap 613 */ 614 endWrap(): RdbPredicates; 615 616 /** 617 * Adds an or condition to the RdbPredicates. 618 * This method is similar to or of the SQL statement. 619 * 620 * @returns { RdbPredicates } Returns the {@link RdbPredicates} with the or condition. 621 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 622 * @since 7 623 * @deprecated since 9 624 * @useinstead ohos.data.relationalStore.RdbPredicates.or 625 */ 626 or(): RdbPredicates; 627 628 /** 629 * Adds an and condition to the RdbPredicates. 630 * This method is similar to or of the SQL statement. 631 * 632 * @returns { RdbPredicates } Returns the {@link RdbPredicates} with the or condition. 633 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 634 * @since 7 635 * @deprecated since 9 636 * @useinstead ohos.data.relationalStore.RdbPredicates.and 637 */ 638 and(): RdbPredicates; 639 640 /** 641 * Configure the RdbPredicates to match the field whose data type is string and value 642 * contains a specified value. 643 * This method is similar to contains of the SQL statement. 644 * 645 * @param { string } field - Indicates the column name in the database table. 646 * @param { string } value - Indicates the value to match with the {@link RdbPredicates}. 647 * @returns { RdbPredicates } - The {@link RdbPredicates} self. 648 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 649 * @since 7 650 * @deprecated since 9 651 * @useinstead ohos.data.relationalStore.RdbPredicates.contains 652 */ 653 contains(field: string, value: string): RdbPredicates; 654 655 /** 656 * Configure the RdbPredicates to match the field whose data type is string and value starts 657 * with a specified string. 658 * This method is similar to value% of the SQL statement. 659 * 660 * @param { string } field - Indicates the column name in the database table. 661 * @param { string } value - Indicates the value to match with the {@link RdbPredicates}. 662 * @returns { RdbPredicates } - The {@link RdbPredicates} self. 663 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 664 * @since 7 665 * @deprecated since 9 666 * @useinstead ohos.data.relationalStore.RdbPredicates.beginsWith 667 */ 668 beginsWith(field: string, value: string): RdbPredicates; 669 670 /** 671 * Configure the RdbPredicates to match the field whose data type is string and value 672 * ends with a specified string. 673 * This method is similar to %value of the SQL statement. 674 * 675 * @param { string } field - Indicates the column name in the database table. 676 * @param { string } value - Indicates the value to match with the {@link RdbPredicates}. 677 * @returns { RdbPredicates } - The {@link RdbPredicates} self. 678 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 679 * @since 7 680 * @deprecated since 9 681 * @useinstead ohos.data.relationalStore.RdbPredicates.endsWith 682 */ 683 endsWith(field: string, value: string): RdbPredicates; 684 685 /** 686 * Configure the RdbPredicates to match the fields whose value is null. 687 * This method is similar to is null of the SQL statement. 688 * 689 * @param { string } field - Indicates the column name in the database table. 690 * @returns { RdbPredicates } - The {@link RdbPredicates} self. 691 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 692 * @since 7 693 * @deprecated since 9 694 * @useinstead ohos.data.relationalStore.RdbPredicates.isNull 695 */ 696 isNull(field: string): RdbPredicates; 697 698 /** 699 * Configure the RdbPredicates to match the specified fields whose value is not null. 700 * This method is similar to is not null of the SQL statement. 701 * 702 * @param { string } field - Indicates the column name in the database table. 703 * @returns { RdbPredicates } - The {@link RdbPredicates} self. 704 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 705 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 706 * @since 7 707 * @deprecated since 9 708 * @useinstead ohos.data.relationalStore.RdbPredicates.isNotNull 709 */ 710 isNotNull(field: string): RdbPredicates; 711 712 /** 713 * Configure the RdbPredicates to match the fields whose data type is string and value is 714 * similar to a specified string. 715 * This method is similar to like of the SQL statement. 716 * 717 * @param { string } field - Indicates the column name in the database table. 718 * @param { string } value - Indicates the value to match with the {@link RdbPredicates}. 719 * @returns { RdbPredicates } - The {@link RdbPredicates} that match the specified field. 720 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 721 * @since 7 722 * @deprecated since 9 723 * @useinstead ohos.data.relationalStore.RdbPredicates.like 724 */ 725 like(field: string, value: string): RdbPredicates; 726 727 /** 728 * Configure RdbPredicates to match the specified field whose data type is string and the value contains 729 * a wildcard. 730 * Different from like, the input parameters of this method are case-sensitive. 731 * 732 * @param { string } field - Indicates the column name in the database table. 733 * @param { string } value - Indicates the value to match with the {@link RdbPredicates}. 734 * @returns { RdbPredicates } - The SQL statement with the specified {@link RdbPredicates}. 735 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 736 * @since 7 737 * @deprecated since 9 738 * @useinstead ohos.data.relationalStore.RdbPredicates.glob 739 */ 740 glob(field: string, value: string): RdbPredicates; 741 742 /** 743 * Configure RdbPredicates to match the specified field whose data type is string and the value contains 744 * a wildcard. 745 * 746 * @param { string } field - Indicates the column name. 747 * @param { ValueType } low - Indicates the minimum value. 748 * @param { ValueType } high - Indicates the maximum value. 749 * @returns { RdbPredicates } - The SQL statement with the specified {@link RdbPredicates}. 750 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 751 * @since 7 752 * @deprecated since 9 753 * @useinstead ohos.data.relationalStore.RdbPredicates.between 754 */ 755 between(field: string, low: ValueType, high: ValueType): RdbPredicates; 756 757 /** 758 * Configure RdbPredicates to match the specified field whose data type is int and value is 759 * out of a given range. 760 * 761 * @param { string } field - Indicates the column name in the database table. 762 * @param { ValueType } low - Indicates the minimum value. 763 * @param { ValueType } high - Indicates the maximum value to. 764 * @returns { RdbPredicates } - The SQL statement with the specified {@link RdbPredicates}. 765 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 766 * @since 7 767 * @deprecated since 9 768 * @useinstead ohos.data.relationalStore.RdbPredicates.notBetween 769 */ 770 notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates; 771 772 /** 773 * Restricts the value of the field to be greater than the specified value. 774 * 775 * @param { string } field - Indicates the column name in the database table. 776 * @param { ValueType } value - Indicates the value to match with the {@link RdbPredicates}. 777 * @returns { RdbPredicates } - The SQL query statement with the specified {@link RdbPredicates}. 778 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 779 * @since 7 780 * @deprecated since 9 781 * @useinstead ohos.data.relationalStore.RdbPredicates.greaterThan 782 */ 783 greaterThan(field: string, value: ValueType): RdbPredicates; 784 785 /** 786 * Restricts the value of the field to be smaller than the specified value. 787 * 788 * @param { string } field - Indicates the column name in the database table. 789 * @param { ValueType } value - Indicates the value to match with the {@link RdbPredicates}. 790 * @returns { RdbPredicates } - The SQL query statement with the specified {@link RdbPredicates}. 791 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 792 * @since 7 793 * @deprecated since 9 794 * @useinstead ohos.data.relationalStore.RdbPredicates.lessThan 795 */ 796 lessThan(field: string, value: ValueType): RdbPredicates; 797 798 /** 799 * Restricts the value of the field to be greater than or equal to the specified value. 800 * 801 * @param { string } field - Indicates the column name in the database table. 802 * @param { ValueType } value - Indicates the value to match with the {@link RdbPredicates}. 803 * @returns { RdbPredicates } - The SQL query statement with the specified {@link RdbPredicates}. 804 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 805 * @since 7 806 * @deprecated since 9 807 * @useinstead ohos.data.relationalStore.RdbPredicates.greaterThanOrEqualTo 808 */ 809 greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates; 810 811 /** 812 * Restricts the value of the field to be smaller than or equal to the specified value. 813 * 814 * @param { string } field - Indicates the column name in the database table. 815 * @param { ValueType } value - Indicates the value to match with the {@link RdbPredicates}. 816 * @returns { RdbPredicates } - The SQL query statement with the specified {@link RdbPredicates}. 817 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 818 * @since 7 819 * @deprecated since 9 820 * @useinstead ohos.data.relationalStore.RdbPredicates.lessThanOrEqualTo 821 */ 822 lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates; 823 824 /** 825 * Restricts the ascending order of the return list. When there are several orders, 826 * the one close to the head has the highest priority. 827 * 828 * @param { string } field - Indicates the column name for sorting the return list. 829 * @returns { RdbPredicates } - The SQL query statement with the specified {@link RdbPredicates}. 830 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 831 * @since 7 832 * @deprecated since 9 833 * @useinstead ohos.data.relationalStore.RdbPredicates.orderByAsc 834 */ 835 orderByAsc(field: string): RdbPredicates; 836 837 /** 838 * Restricts the descending order of the return list. When there are several orders, 839 * the one close to the head has the highest priority. 840 * 841 * @param { string } field - Indicates the column name for sorting the return list. 842 * @returns { RdbPredicates } - The SQL query statement with the specified {@link RdbPredicates}. 843 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 844 * @since 7 845 * @deprecated since 9 846 * @useinstead ohos.data.relationalStore.RdbPredicates.orderByDesc 847 */ 848 orderByDesc(field: string): RdbPredicates; 849 850 /** 851 * Restricts each row of the query result to be unique. 852 * 853 * @returns { RdbPredicates } - The SQL query statement with the specified {@link RdbPredicates}. 854 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 855 * @since 7 856 * @deprecated since 9 857 * @useinstead ohos.data.relationalStore.RdbPredicates.distinct 858 */ 859 distinct(): RdbPredicates; 860 861 /** 862 * Restricts the max number of return records. 863 * 864 * @param { number } value - Indicates the max length of the return list. 865 * @returns { RdbPredicates } - The SQL query statement with the specified {@link RdbPredicates}. 866 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 867 * @since 7 868 * @deprecated since 9 869 * @useinstead ohos.data.relationalStore.RdbPredicates.limitAs 870 */ 871 limitAs(value: number): RdbPredicates; 872 873 /** 874 * Configure RdbPredicates to specify the start position of the returned result. 875 * Use this method together with limit(int). 876 * 877 * @param { number } rowOffset - Indicates the start position of the returned result. The value is a positive integer. 878 * @returns { RdbPredicates } - The SQL query statement with the specified {@link RdbPredicates}. 879 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 880 * @since 7 881 * @deprecated since 9 882 * @useinstead ohos.data.relationalStore.RdbPredicates.offsetAs 883 */ 884 offsetAs(rowOffset: number): RdbPredicates; 885 886 /** 887 * Configure RdbPredicates to group query results by specified columns. 888 * 889 * @param { Array<string> } fields - Indicates the specified columns by which query results are grouped. 890 * @returns { RdbPredicates } - The SQL query statement with the specified {@link RdbPredicates}. 891 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 892 * @since 7 893 * @deprecated since 9 894 * @useinstead ohos.data.relationalStore.RdbPredicates.groupBy 895 */ 896 groupBy(fields: Array<string>): RdbPredicates; 897 898 /** 899 * Configure RdbPredicates to specify the index column. 900 * Before using this method, you need to create an index column. 901 * 902 * @param { string } field - Indicates the name of the index column. 903 * @returns { RdbPredicates } - The SQL statement with the specified {@link RdbPredicates}. 904 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 905 * @since 7 906 * @deprecated since 9 907 * @useinstead ohos.data.relationalStore.RdbPredicates.indexedBy 908 */ 909 indexedBy(field: string): RdbPredicates; 910 911 /** 912 * Configure RdbPredicates to match the specified field whose data type is ValueType array and values 913 * are within a given range. 914 * 915 * @param { string } field - Indicates the column name in the database table. 916 * @param { Array<ValueType> } value - Indicates the values to match with {@link RdbPredicates}. 917 * @returns { RdbPredicates } - The SQL statement with the specified {@link RdbPredicates}. 918 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 919 * @since 7 920 * @deprecated since 9 921 * @useinstead ohos.data.relationalStore.RdbPredicates.in 922 */ 923 in(field: string, value: Array<ValueType>): RdbPredicates; 924 925 /** 926 * Configure RdbPredicates to match the specified field whose data type is ValueType array and values 927 * are out of a given range. 928 * 929 * @param { string } field - Indicates the column name in the database table. 930 * @param { Array<ValueType> } value - Indicates the values to match with {@link RdbPredicates}. 931 * @returns { RdbPredicates } - The SQL statement with the specified {@link RdbPredicates}. 932 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core 933 * @since 7 934 * @deprecated since 9 935 * @useinstead ohos.data.relationalStore.RdbPredicates.notIn 936 */ 937 notIn(field: string, value: Array<ValueType>): RdbPredicates; 938 } 939 940 export type ResultSet = _ResultSet; 941} 942 943export default rdb; 944