1# @ohos.data.dataSharePredicates (DataShare Predicates) 2 3You can use **DataSharePredicates** to specify conditions for [updating](js-apis-data-dataShare.md#update), [deleting](js-apis-data-dataShare.md#delete), and [querying](js-apis-data-dataShare.md#query) data when **DataShare** is used to manage data. 4 5The APIs provided by **DataSharePredicates** correspond to the filter criteria of the database. Before using the APIs, you need to have basic database knowledge. 6 7> **NOTE** 8> 9> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 10> 11> The APIs provided by this module are system APIs. 12 13 14## Modules to Import 15 16```ts 17import dataSharePredicates from '@ohos.data.dataSharePredicates'; 18``` 19 20## DataSharePredicates 21Provides methods for setting different **DataSharePredicates** objects. 22 23### equalTo 24 25equalTo(field: string, value: ValueType): DataSharePredicates 26 27Sets a **DataSharePredicates** object to search for the data that is equal to the specified value. 28 29Currently, only the relational database (RDB) and key-value database (KVDB, schema) support this **DataSharePredicates** object. 30 31**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 32 33**Parameters** 34 35| Name| Type | Mandatory| Description | 36| ------ | --------------------------------------------------- | ---- | ---------------------- | 37| field | string | Yes | Column name in the database table. | 38| value | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | Value to match.| 39 40**Return value** 41 42| Type | Description | 43| ------------------------------------------- | -------------------------- | 44| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 45 46**Example** 47 48```ts 49let predicates = new dataSharePredicates.DataSharePredicates() 50predicates.equalTo("NAME", "Rose") 51``` 52 53### notEqualTo 54 55notEqualTo(field: string, value: ValueType): DataSharePredicates 56 57Sets a **DataSharePredicates** object to search for the data that is not equal to the specified value. 58 59Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 60 61**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 62 63**Parameters** 64 65| Name| Type | Mandatory| Description | 66| ------ | --------------------------------------------------- | ---- | ---------------------- | 67| field | string | Yes | Column name in the database table. | 68| value | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | Value to match.| 69 70**Return value** 71 72| Type | Description | 73| ------------------------------------------- | -------------------------- | 74| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 75 76**Example** 77 78```ts 79let predicates = new dataSharePredicates.DataSharePredicates() 80predicates.notEqualTo("NAME", "Rose") 81``` 82 83### beginWrap 84 85beginWrap(): DataSharePredicates 86 87Adds a left parenthesis to this **DataSharePredicates**. 88 89Currently, only the RDB supports this **DataSharePredicates** object. 90 91**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 92 93**Return value** 94 95| Type | Description | 96| ------------------------------------------- | ---------------------- | 97| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object with a left parenthesis.| 98 99**Example** 100 101```ts 102let predicates = new dataSharePredicates.DataSharePredicates() 103predicates.equalTo("NAME", "lisi") 104 .beginWrap() 105 .equalTo("AGE", 18) 106 .or() 107 .equalTo("SALARY", 200.5) 108 .endWrap() 109``` 110 111### endWrap 112 113endWrap(): DataSharePredicates 114 115Adds a right parenthesis to this **DataSharePredicates** object. 116 117Currently, only the RDB supports this **DataSharePredicates** object. 118 119**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 120 121**Return value** 122 123| Type | Description | 124| ------------------------------------------- | ---------------------- | 125| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object with a right parenthesis.| 126 127**Example** 128 129```ts 130let predicates = new dataSharePredicates.DataSharePredicates() 131predicates.equalTo("NAME", "lisi") 132 .beginWrap() 133 .equalTo("AGE", 18) 134 .or() 135 .equalTo("SALARY", 200.5) 136 .endWrap() 137``` 138 139### or 140 141or(): DataSharePredicates 142 143Adds the OR condition to this **DataSharePredicates** object. 144 145Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 146 147**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 148 149**Return value** 150 151| Type | Description | 152| ------------------------------------------- | ---------------------- | 153| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object with the OR condition.| 154 155**Example** 156 157```ts 158let predicates = new dataSharePredicates.DataSharePredicates() 159predicates.equalTo("NAME", "lisi") 160 .or() 161 .equalTo("NAME", "Rose") 162``` 163 164### and 165 166and(): DataSharePredicates 167 168Adds the AND condition to this **DataSharePredicates** object. 169 170Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 171 172**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 173 174**Return value** 175 176| Type | Description | 177| ------------------------------------------- | ---------------------- | 178| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object with the AND condition.| 179 180**Example** 181 182```ts 183let predicates = new dataSharePredicates.DataSharePredicates() 184predicates.equalTo("NAME", "lisi") 185 .and() 186 .equalTo("SALARY", 200.5) 187``` 188 189### contains 190 191contains(field: string, value: string): DataSharePredicates 192 193Sets a **DataSharePredicates** object to search for the data that contains the specified value. 194 195Currently, only the RDB supports this **DataSharePredicates** object. 196 197**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 198 199**Parameters** 200 201| Name| Type | Mandatory| Description | 202| ------ | ------ | ---- | -------------------- | 203| field | string | Yes | Column name in the database table. | 204| value | string | Yes | Value to match.| 205 206**Return value** 207 208| Type | Description | 209| ------------------------------------------- | -------------------------- | 210| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 211 212**Example** 213 214```ts 215let predicates = new dataSharePredicates.DataSharePredicates() 216predicates.contains("NAME", "os") 217``` 218 219### beginsWith 220 221beginsWith(field: string, value: string): DataSharePredicates 222 223Sets a **DataSharePredicates** object to search for the data that begins with the specified value. 224 225Currently, only the RDB supports this **DataSharePredicates** object. 226 227**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 228 229**Parameters** 230 231| Name| Type | Mandatory| Description | 232| ------ | ------ | ---- | ---------------------- | 233| field | string | Yes | Column name in the database table. | 234| value | string | Yes | Start value to match.| 235 236**Return value** 237 238| Type | Description | 239| ------------------------------------------- | -------------------------- | 240| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 241 242**Example** 243 244```ts 245let predicates = new dataSharePredicates.DataSharePredicates() 246predicates.beginsWith("NAME", "os") 247``` 248 249### endsWith 250 251endsWith(field: string, value: string): DataSharePredicates 252 253Sets a **DataSharePredicates** object to search for the data that ends with the specified value. 254 255Currently, only the RDB supports this **DataSharePredicates** object. 256 257**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 258 259**Parameters** 260 261| Name| Type | Mandatory| Description | 262| ------ | ------ | ---- | ---------------------- | 263| field | string | Yes | Column name in the database table. | 264| value | string | Yes | End value to match.| 265 266**Return value** 267 268| Type | Description | 269| ------------------------------------------- | -------------------------- | 270| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 271 272**Example** 273 274```ts 275let predicates = new dataSharePredicates.DataSharePredicates() 276predicates.endsWith("NAME", "os") 277``` 278 279### isNull 280 281isNull(field: string): DataSharePredicates 282 283Sets a **DataSharePredicates** object to search for the data whose value is null. 284 285Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 286 287**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 288 289**Parameters** 290 291| Name| Type | Mandatory| Description | 292| ------ | ------ | ---- | ------------------ | 293| field | string | Yes | Column name in the database table.| 294 295**Return value** 296 297| Type | Description | 298| ------------------------------------------- | -------------------------- | 299| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 300 301**Example** 302 303```ts 304let predicates = new dataSharePredicates.DataSharePredicates() 305predicates.isNull("NAME") 306``` 307 308### isNotNull 309 310isNotNull(field: string): DataSharePredicates 311 312Sets a **DataSharePredicates** object to search for the data whose value is not null. 313 314Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 315 316**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 317 318**Parameters** 319 320| Name| Type | Mandatory| Description | 321| ------ | ------ | ---- | ------------------ | 322| field | string | Yes | Column name in the database table.| 323 324**Return value** 325 326| Type | Description | 327| ------------------------------------------- | -------------------------- | 328| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 329 330**Example** 331 332```ts 333let predicates = new dataSharePredicates.DataSharePredicates() 334predicates.isNotNull("NAME") 335``` 336 337### like 338 339like(field: string, value: string): DataSharePredicates 340 341Sets a **DataSharePredicates** object to search for the data that matches the specified wildcard expression. 342 343Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 344 345**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 346 347**Parameters** 348 349| Name| Type | Mandatory| Description | 350| ------ | ------ | ---- | ---------------------- | 351| field | string | Yes | Column name in the database table. | 352| value | string | Yes | Wildcard expression to match.<br>In the expression, '%' represents zero, one, or more digits or characters, and '_' represents a single digit or character. It is case insensitive.| 353 354**Return value** 355 356| Type | Description | 357| ------------------------------------------- | -------------------------- | 358| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 359 360**Example** 361 362```ts 363let predicates = new dataSharePredicates.DataSharePredicates() 364predicates.like("NAME", "%os%") 365``` 366 367### unlike 368 369unlike(field: string, value: string): DataSharePredicates 370 371Sets a **DataSharePredicates** object to search for the data that does not match the specified wildcard expression. 372 373Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 374 375**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 376 377**Parameters** 378 379| Name| Type | Mandatory| Description | 380| ------ | ------ | ---- | ---------------------- | 381| field | string | Yes | Column name in the database table. | 382| value | string | Yes | Wildcard expression to match.<br>In the expression, '%' represents zero, one, or more digits or characters, and '_' represents a single digit or character. It is case insensitive.| 383 384**Return value** 385 386| Type | Description | 387| ------------------------------------------- | -------------------------- | 388| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 389 390**Example** 391 392```ts 393let predicates = new dataSharePredicates.DataSharePredicates() 394predicates.unlike("NAME", "%os%") 395``` 396 397### glob 398 399glob(field: string, value: string): DataSharePredicates 400 401Sets a **DataSharePredicates** object to search for the data that matches the specified wildcard expression. 402 403Currently, only the RDB supports this **DataSharePredicates** object. 404 405**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 406 407**Parameters** 408 409| Name| Type | Mandatory| Description | 410| ------ | ------ | ---- | ---------------------- | 411| field | string | Yes | Column name in the database table. | 412| value | string | Yes | Wildcard expression to match.<br>In the expression, '*' represents zero, one, or more digits or characters, and '?' represents a single digit or character. It is case sensitive.| 413 414**Return value** 415 416| Type | Description | 417| ------------------------------------------- | -------------------------- | 418| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 419 420**Example** 421 422```ts 423let predicates = new dataSharePredicates.DataSharePredicates() 424predicates.glob("NAME", "?h*g") 425``` 426 427### between 428 429between(field: string, low: ValueType, high: ValueType): DataSharePredicates 430 431Sets a **DataSharePredicates** object to search for the data that is within the specified range, including the start and end values. 432 433Currently, only the RDB supports this **DataSharePredicates** object. 434 435**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 436 437**Parameters** 438 439| Name| Type | Mandatory| Description | 440| ------ | --------------------------------------------------- | ---- | ------------------------ | 441| field | string | Yes | Column name in the database table. | 442| low | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | The lowest value of the range.| 443| high | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | The highest value of the range.| 444 445**Return value** 446 447| Type | Description | 448| ------------------------------------------- | -------------------------- | 449| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 450 451**Example** 452 453```ts 454let predicates = new dataSharePredicates.DataSharePredicates() 455predicates.between("AGE", 10, 50) 456``` 457 458### notBetween 459 460notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates 461 462Sets a **DataSharePredicates** object to search for the data that is out of the specified range, excluding the start and end values. 463 464Currently, only the RDB supports this **DataSharePredicates** object. 465 466**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 467 468**Parameters** 469 470| Name| Type | Mandatory| Description | 471| ------ | --------------------------------------------------- | ---- | ------------------------ | 472| field | string | Yes | Column name in the database table. | 473| low | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | The lowest value of the range.| 474| high | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | The highest value of the range.| 475 476**Return value** 477 478| Type | Description | 479| ------------------------------------------- | -------------------------- | 480| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 481 482**Example** 483 484```ts 485let predicates = new dataSharePredicates.DataSharePredicates() 486predicates.notBetween("AGE", 10, 50) 487``` 488 489### greaterThan 490 491greaterThan(field: string, value: ValueType): DataSharePredicates 492 493Sets a **DataSharePredicates** object to search for the data that is greater than the specified value. 494 495Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 496 497**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 498 499**Parameters** 500 501| Name | Type | Mandatory| Description | 502| ------- | --------- | ---- | ---------------------- | 503| field | string | Yes | Column name in the database table. | 504| value | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | Value to match.| 505 506**Return value** 507 508| Type | Description | 509| ------------------------------------------- | -------------------------- | 510| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 511 512**Example** 513 514```ts 515let predicates = new dataSharePredicates.DataSharePredicates() 516predicates.greaterThan("AGE", 10) 517``` 518 519### lessThan 520 521lessThan(field: string, value: ValueType): DataSharePredicates 522 523Sets a **DataSharePredicates** object to search for the data that is less than the specified value. 524 525Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 526 527**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 528 529**Parameters** 530 531| Name| Type | Mandatory| Description | 532| ------ | --------------------------------------------------- | ---- | ---------------------- | 533| field | string | Yes | Column name in the database table. | 534| value | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | Value to match.| 535 536**Return value** 537 538| Type | Description | 539| ------------------------------------------- | -------------------------- | 540| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 541 542**Example** 543 544```ts 545let predicates = new dataSharePredicates.DataSharePredicates() 546predicates.lessThan("AGE", 50) 547``` 548 549### greaterThanOrEqualTo 550 551greaterThanOrEqualTo(field: string, value: ValueType): DataSharePredicates 552 553Sets a **DataSharePredicates** object to search for the data that is greater than or equal to the specified value. 554 555Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 556 557**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 558 559**Parameters** 560 561| Name | Type | Mandatory| Description | 562| ------- | --------- | ---- | ---------------------- | 563| field | string | Yes | Column name in the database table. | 564| value | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | Value to match.| 565 566**Return value** 567 568| Type | Description | 569| ------------------------------------------- | -------------------------- | 570| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 571 572**Example** 573 574```ts 575let predicates = new dataSharePredicates.DataSharePredicates() 576predicates.greaterThanOrEqualTo("AGE", 10) 577``` 578 579### lessThanOrEqualTo 580 581lessThanOrEqualTo(field: string, value: ValueType): DataSharePredicates 582 583Sets a **DataSharePredicates** object to search for the data that is less than or equal to the specified value. 584 585Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 586 587**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 588 589**Parameters** 590 591| Name | Type | Mandatory| Description | 592| ------- | --------- | ---- | ---------------------- | 593| field | string | Yes | Column name in the database table. | 594| value | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | Value to match.| 595 596**Return value** 597 598| Type | Description | 599| ------------------------------------------- | -------------------------- | 600| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 601 602**Example** 603 604```ts 605let predicates = new dataSharePredicates.DataSharePredicates() 606predicates.lessThanOrEqualTo("AGE", 50) 607``` 608 609### orderByAsc 610 611orderByAsc(field: string): DataSharePredicates 612 613Sets a **DataSharePredicates** object that sorts data in ascending order. 614 615Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 616 617**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 618 619**Parameters** 620 621| Name| Type | Mandatory| Description | 622| ------ | ------ | ---- | ------------------ | 623| field | string | Yes | Column name in the database table.| 624 625**Return value** 626 627| Type | Description | 628| ------------------------------------------- | -------------------------- | 629| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 630 631**Example** 632 633```ts 634let predicates = new dataSharePredicates.DataSharePredicates() 635predicates.orderByAsc("AGE") 636``` 637 638### orderByDesc 639 640orderByDesc(field: string): DataSharePredicates 641 642Sets a **DataSharePredicates** object that sorts data in descending order. 643 644Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 645 646**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 647 648**Parameters** 649 650| Name| Type | Mandatory| Description | 651| ------ | ------ | ---- | ------------------ | 652| field | string | Yes | Column name in the database table.| 653 654**Return value** 655 656| Type | Description | 657| ------------------------------------------- | -------------------------- | 658| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 659 660**Example** 661 662```ts 663let predicates = new dataSharePredicates.DataSharePredicates() 664predicates.orderByDesc("AGE") 665``` 666 667### distinct 668 669distinct(): DataSharePredicates 670 671Sets a **DataSharePredicates** object to filter out duplicate data records. 672 673Currently, only the RDB supports this **DataSharePredicates** object. 674 675**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 676 677**Return value** 678 679| Type | Description | 680| ------------------------------------------- | -------------------------- | 681| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 682 683**Example** 684 685```ts 686let predicates = new dataSharePredicates.DataSharePredicates() 687predicates.equalTo("NAME", "Rose").distinct() 688``` 689 690### limit 691 692limit(total: number, offset: number): DataSharePredicates 693 694Sets a **DataSharePredicates** object to specify the number of results and the start position. 695 696Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 697 698**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 699 700**Parameters** 701 702| Name | Type | Mandatory| Description | 703| -------- | ------ | ---- | -------------- | 704| total | number | Yes | Number of results. | 705| offset | number | Yes | Start position.| 706 707**Return value** 708 709| Type | Description | 710| ------------------------------------------- | -------------------------- | 711| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 712 713**Example** 714 715```ts 716let predicates = new dataSharePredicates.DataSharePredicates() 717predicates.equalTo("NAME", "Rose").limit(10, 3) 718``` 719 720### groupBy 721 722groupBy(fields: Array<string>): DataSharePredicates 723 724Sets a **DataSharePredicates** object group the records according to the specified fields. 725 726Currently, only the RDB supports this **DataSharePredicates** object. 727 728**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 729 730**Parameters** 731 732| Name| Type | Mandatory| Description | 733| ------ | ------------- | ---- | -------------------- | 734| fields | Array<string> | Yes | Names of the columns by which the records are grouped.| 735 736**Return value** 737 738| Type | Description | 739| ------------------------------------------- | -------------------------- | 740| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 741 742**Example** 743 744```ts 745let predicates = new dataSharePredicates.DataSharePredicates() 746predicates.groupBy(["AGE", "NAME"]) 747``` 748 749### indexedBy 750 751indexedBy(field: string): DataSharePredicates 752 753Sets a **DataSharePredicates** object to list data by the specified index. 754 755Currently, only the RDB supports this **DataSharePredicates** object. 756 757**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 758 759**Parameters** 760 761| Name| Type | Mandatory| Description | 762| ------ | ------ | ---- | -------------- | 763| field | string | Yes | Name of the index column.| 764 765**Return value** 766 767| Type | Description | 768| ------------------------------------------- | -------------------------- | 769| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 770 771**Example** 772 773```ts 774let predicates = new dataSharePredicates.DataSharePredicates() 775predicates.indexedBy("SALARY_INDEX") 776``` 777 778### in 779 780in(field: string, value: Array<ValueType>): DataSharePredicates 781 782Sets a **DataSharePredicates** object to search for the data that is within the specified value. 783 784Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 785 786**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 787 788**Parameters** 789 790| Name | Type | Mandatory| Description | 791| ------- | ---------------- | ---- | --------------------------------------- | 792| field | string | Yes| Column name in the database table. | 793| value | Array<[ValueType](js-apis-data-valuesBucket.md#valuetype)> | Yes | Array of the values to match.| 794 795**Return value** 796 797| Type | Description | 798| ------------------------------------------- | -------------------------- | 799| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 800 801**Example** 802 803```ts 804let predicates = new dataSharePredicates.DataSharePredicates() 805predicates.in("AGE", [18, 20]) 806``` 807 808### notIn 809 810notIn(field: string, value: Array<ValueType>): DataSharePredicates 811 812Sets a **DataSharePredicates** object to search for the data that is not in the specified value. 813 814Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. 815 816**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 817 818**Parameters** 819 820| Name | Type | Mandatory| Description | 821| ------- | ---------------- | ---- | --------------------------------------- | 822| field | string | Yes | Column name in the database table. | 823| value | Array<[ValueType](js-apis-data-valuesBucket.md#valuetype)> | Yes | Array of the values to match.| 824 825**Return value** 826 827| Type | Description | 828| ------------------------------------------- | -------------------------- | 829| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 830 831**Example** 832 833```ts 834let predicates = new dataSharePredicates.DataSharePredicates() 835predicates.notIn("NAME", ["Lisa", "Rose"]) 836``` 837 838### prefixKey 839 840prefixKey(prefix: string): DataSharePredicates 841 842Sets a **DataSharePredicates** object to search for the data with the specified key prefix. 843 844Currently, only the KVDB supports this **DataSharePredicates** object. 845 846**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 847 848**Parameters** 849 850| Name| Type | Mandatory| Description | 851| ------ | ------ | ---- | -------------- | 852| prefix | string | Yes | Key prefix to match.| 853 854**Return value** 855 856| Type | Description | 857| ------------------------------------------- | -------------------------- | 858| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 859 860**Example** 861 862```ts 863let predicates = new dataSharePredicates.DataSharePredicates() 864predicates.prefixKey("NAME") 865``` 866 867### inKeys 868 869inKeys(keys: Array<string>): DataSharePredicates 870 871Sets a **DataSharePredicates** object to search for the data whose keys are within the given range. 872 873Currently, only the KVDB supports this **DataSharePredicates** object. 874 875**System capability**: SystemCapability.DistributedDataManager.DataShare.Core 876 877**Parameters** 878 879| Name| Type | Mandatory| Description | 880| ------ | ------------- | ---- | ------------------ | 881| inKeys | Array<string> | Yes | Array of the keys to match.| 882 883**Return value** 884 885| Type | Description | 886| ------------------------------------------- | -------------------------- | 887| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object created.| 888 889**Example** 890 891```ts 892let predicates = new dataSharePredicates.DataSharePredicates() 893predicates.inKeys(["Lisa", "Rose"]) 894``` 895