1# @ohos.data.dataAbility (DataAbility Predicates)
2
3The **DataAbility** module provides APIs to create predicates for querying data from relational database (RDB) stores.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9
10## Modules to Import
11
12```js
13import { dataAbility } from '@kit.ArkData';
14```
15
16## dataAbility.createRdbPredicates
17
18createRdbPredicates(name: string, dataAbilityPredicates: DataAbilityPredicates): rdb.RdbPredicates
19
20Creates an **RdbPredicates** object with the specified table name and **DataAbilityPredicates** object.
21
22**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
23
24**Parameters**
25
26| Name | Type | Mandatory | Description |
27| -------- | -------- | -------- | -------- |
28| name | string | Yes | Name of a database table. |
29| dataAbilityPredicates | [DataAbilityPredicates](#dataabilitypredicates) | Yes | **DataAbilityPredicates** object.   |
30
31**Return value**
32
33| Type | Description |
34| -------- | -------- |
35| rdb.[RdbPredicates](js-apis-data-rdb.md#rdbpredicates) | **RdbPredicates** object created. |
36
37**Example**
38
39  ```js
40  let dataAbilityPredicates = new dataAbility.DataAbilityPredicates()
41  dataAbilityPredicates.equalTo("NAME", "Rose")
42  // EMPLOYEE is a table created in a relational database.
43  let predicates = dataAbility.createRdbPredicates("EMPLOYEE", dataAbilityPredicates)
44  ```
45
46## DataAbilityPredicates
47
48Provides predicates for implementing diverse query methods.
49
50**Initialization**
51
52  ```js
53  let dataAbilityPredicates = new dataAbility.DataAbilityPredicates()
54  ```
55
56### equalTo
57
58equalTo(field: string, value: ValueType): DataAbilityPredicates
59
60Sets a **DataAbilityPredicates** object to match the field with data type **ValueType** and value equals to the specified value.
61
62This API is similar to the SQL equal to (=) operator.
63
64**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
65
66**Parameters**
67
68| Name | Type | Mandatory | Description |
69| -------- | -------- | -------- | -------- |
70| field | string | Yes | Column name in the table. |
71| value | [ValueType](#valuetype) | Yes | Value to match the **DataAbilityPredicates**. |
72
73**Return value**
74
75| Type | Description |
76| -------- | -------- |
77| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
78
79**Example**
80
81  ```js
82  dataAbilityPredicates.equalTo("NAME", "lisi")
83  ```
84
85### notEqualTo
86
87notEqualTo(field: string, value: ValueType): DataAbilityPredicates
88
89Sets a **DataAbilityPredicates** object to match the field with data type **ValueType** and value not equal to the specified value.
90
91This API is similar to the SQL not equal (!=) operator.
92
93**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
94
95**Parameters**
96
97| Name | Type | Mandatory | Description |
98| -------- | -------- | -------- | -------- |
99| field | string | Yes | Column name in the table. |
100| value | [ValueType](#valuetype) | Yes | Value to match the **DataAbilityPredicates**. |
101
102**Return value**
103
104| Type | Description |
105| -------- | -------- |
106| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
107
108**Example**
109
110  ```js
111  dataAbilityPredicates.notEqualTo("NAME", "lisi")
112  ```
113
114### beginWrap
115
116beginWrap(): DataAbilityPredicates
117
118Adds a left parenthesis to this **DataAbilityPredicates**. This API is similar to "(" in an SQL statement and must be used with **endWrap**.
119
120**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
121
122**Return value**
123
124| Type | Description |
125| -------- | -------- |
126| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a left parenthesis. |
127
128**Example**
129
130  ```js
131  dataAbilityPredicates.equalTo("NAME", "lisi")
132      .beginWrap()
133      .equalTo("AGE", 18)
134      .or()
135      .equalTo("SALARY", 200.5)
136      .endWrap()
137  ```
138
139### endWrap
140
141endWrap(): DataAbilityPredicates
142
143Adds a right parenthesis to this **DataAbilityPredicates**. This API is similar to ")" in an SQL statement and must be used with **beginWrap**.
144
145**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
146
147**Return value**
148
149| Type | Description |
150| -------- | -------- |
151| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a right parenthesis. |
152
153**Example**
154
155  ```js
156  dataAbilityPredicates.equalTo("NAME", "lisi")
157      .beginWrap()
158      .equalTo("AGE", 18)
159      .or()
160      .equalTo("SALARY", 200.5)
161      .endWrap()
162  ```
163
164### or
165
166or(): DataAbilityPredicates
167
168Adds the OR condition to this **DataAbilityPredicates**.
169
170This API is similar to the SQL **or** operator.
171
172**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
173
174**Return value**
175
176| Type | Description |
177| -------- | -------- |
178| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the OR condition. |
179
180**Example**
181
182  ```js
183  dataAbilityPredicates.equalTo("NAME", "Lisa")
184      .or()
185      .equalTo("NAME", "Rose")
186  ```
187
188### and
189
190and(): DataAbilityPredicates
191
192Adds the AND condition to this **DataAbilityPredicates**.
193
194**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
195
196**Return value**
197
198| Type | Description |
199| -------- | -------- |
200| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the AND condition. |
201
202**Example**
203
204  ```js
205  dataAbilityPredicates.equalTo("NAME", "Lisa")
206      .and()
207      .equalTo("SALARY", 200.5)
208  ```
209
210### contains
211
212contains(field: string, value: string): DataAbilityPredicates
213
214Sets a **DataAbilityPredicates** object to match a string containing the specified value.
215
216**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
217
218**Parameters**
219
220| Name | Type | Mandatory | Description |
221| -------- | -------- | -------- | -------- |
222| field | string | Yes | Column name in the table. |
223| value | string | Yes | Value to match the **DataAbilityPredicates**. |
224
225**Return value**
226
227| Type | Description |
228| -------- | -------- |
229| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
230
231**Example**
232
233  ```js
234  dataAbilityPredicates.contains("NAME", "os")
235  ```
236
237### beginsWith
238
239beginsWith(field: string, value: string): DataAbilityPredicates
240
241Sets a **DataAbilityPredicates** object to match a string that starts with the specified value.
242
243This API is similar to the percent sign (%) in SQL statements.
244
245**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
246
247**Parameters**
248
249| Name | Type | Mandatory | Description |
250| -------- | -------- | -------- | -------- |
251| field | string | Yes | Column name in the table. |
252| value | string | Yes | Value to match the **DataAbilityPredicates**. |
253
254**Return value**
255
256| Type | Description |
257| -------- | -------- |
258| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
259
260**Example**
261
262  ```js
263  dataAbilityPredicates.beginsWith("NAME", "os")
264  ```
265
266### endsWith
267
268endsWith(field: string, value: string): DataAbilityPredicates
269
270Sets a **DataAbilityPredicates** object to match a string that ends with the specified value.
271
272This API is similar to the percent sign (%) in SQL statements.
273
274**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
275
276**Parameters**
277
278| Name | Type | Mandatory | Description |
279| -------- | -------- | -------- | -------- |
280| field | string | Yes | Column name in the table. |
281| value | string | Yes | Value to match the **DataAbilityPredicates**. |
282
283**Return value**
284
285| Type | Description |
286| -------- | -------- |
287| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
288
289**Example**
290
291  ```
292  dataAbilityPredicates.endsWith("NAME", "se")
293  ```
294
295### isNull
296
297isNull(field: string): DataAbilityPredicates
298
299Sets a **DataAbilityPredicates** object to match the field whose value is null.
300
301**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
302
303**Parameters**
304
305| Name | Type | Mandatory | Description |
306| -------- | -------- | -------- | -------- |
307| field | string | Yes | Column name in the table. |
308
309**Return value**
310
311| Type | Description |
312| -------- | -------- |
313| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
314
315**Example**
316
317  ```js
318  dataAbilityPredicates.isNull("NAME")
319  ```
320
321### isNotNull
322
323isNotNull(field: string): DataAbilityPredicates
324
325Sets a **DataAbilityPredicates** object to match the field whose value is not null.
326
327**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
328
329**Parameters**
330
331| Name | Type | Mandatory | Description |
332| -------- | -------- | -------- | -------- |
333| field | string | Yes | Column name in the table. |
334
335**Return value**
336
337| Type | Description |
338| -------- | -------- |
339| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
340
341**Example**
342
343  ```js
344  dataAbilityPredicates.isNotNull("NAME")
345  ```
346
347### like
348
349like(field: string, value: string): DataAbilityPredicates
350
351Sets a **DataAbilityPredicates** object to match a string that is similar to the specified value.
352
353This API is similar to the SQL **like** statement.
354
355**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
356
357**Parameters**
358
359| Name | Type | Mandatory | Description |
360| -------- | -------- | -------- | -------- |
361| field | string | Yes | Column name in the table. |
362| value | string | Yes | Value to match the **DataAbilityPredicates**. |
363
364**Return value**
365
366| Type | Description |
367| -------- | -------- |
368| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
369
370**Example**
371
372  ```js
373  dataAbilityPredicates.like("NAME", "%os%")
374  ```
375
376### glob
377
378glob(field: string, value: string): DataAbilityPredicates
379
380Sets a **DataAbilityPredicates** object to match the specified string. Different from **like**, the input parameters of this API are case-sensitive.
381
382**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
383
384**Parameters**
385
386| Name | Type | Mandatory | Description |
387| -------- | -------- | -------- | -------- |
388| field | string | Yes | Column name in the table. |
389| value | string | Yes | Value to match the **DataAbilityPredicates**. |
390
391**Return value**
392
393| Type | Description |
394| -------- | -------- |
395| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
396
397**Example**
398
399  ```js
400  dataAbilityPredicates.glob("NAME", "?h*g")
401
402  // Only the data with name of Lisa matches the specified predicate.
403  dataAbilityPredicates.glob("NAME", "Lisa")
404
405  // Only the data with name of lisa matches the specified predicate.
406  dataAbilityPredicates.glob("NAME", "lisa")
407  ```
408
409### between
410
411between(field: string, low: ValueType, high: ValueType): DataAbilityPredicates
412
413Sets a **DataAbilityPredicates** object to match a field whose data type is **ValueType** and value is within the specified range.
414
415**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
416
417**Parameters**
418
419| Name | Type | Mandatory | Description |
420| -------- | -------- | -------- | -------- |
421| field | string | Yes | Column name in the table. |
422| low | [ValueType](#valuetype) | Yes | Minimum value to match the **DataAbilityPredicates**. |
423| high | [ValueType](#valuetype) | Yes | Maximum value to match the **DataAbilityPredicates**. |
424
425**Return value**
426
427| Type | Description |
428| -------- | -------- |
429| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
430
431**Example**
432
433  ```js
434  dataAbilityPredicates.between("AGE", 10, 50)
435  ```
436
437### notBetween
438
439notBetween(field: string, low: ValueType, high: ValueType): DataAbilityPredicates
440
441Sets a **DataAbilityPredicates** object to match the field with data type **ValueType** and value out of the specified range.
442
443**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
444
445**Parameters**
446
447| Name | Type | Mandatory | Description |
448| -------- | -------- | -------- | -------- |
449| field | string | Yes | Column name in the table. |
450| low | [ValueType](#valuetype) | Yes | Minimum value to match the **DataAbilityPredicates**. |
451| high | [ValueType](#valuetype) | Yes | Maximum value to match the **DataAbilityPredicates**. |
452
453**Return value**
454
455| Type | Description |
456| -------- | -------- |
457| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
458
459**Example**
460
461  ```js
462  dataAbilityPredicates.notBetween("AGE", 10, 50)
463  ```
464
465### greaterThan
466
467greaterThan(field: string, value: ValueType): DataAbilityPredicates
468
469Sets a **DataAbilityPredicates** object to match the field with data type **ValueType** and value greater than the specified value.
470
471**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
472
473**Parameters**
474
475| Name | Type | Mandatory | Description |
476| -------- | -------- | -------- | -------- |
477| field | string | Yes | Column name in the table. |
478| value | [ValueType](#valuetype) | Yes | Value to match the **DataAbilityPredicates**. |
479
480**Return value**
481
482| Type | Description |
483| -------- | -------- |
484| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
485
486**Example**
487
488  ```js
489  dataAbilityPredicates.greaterThan("AGE", 18)
490  ```
491
492### lessThan
493
494lessThan(field: string, value: ValueType): DataAbilityPredicates
495
496Sets a **DataAbilityPredicates** object to match the field with data type **ValueType** and value less than the specified value.
497
498**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
499
500**Parameters**
501
502| Name | Type | Mandatory | Description |
503| -------- | -------- | -------- | -------- |
504| field | string | Yes | Column name in the table. |
505| value | [ValueType](#valuetype) | Yes | Value to match the **DataAbilityPredicates**. |
506
507**Return value**
508
509| Type | Description |
510| -------- | -------- |
511| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
512
513**Example**
514
515  ```js
516  dataAbilityPredicates.lessThan("AGE", 20)
517  ```
518
519### greaterThanOrEqualTo
520
521greaterThanOrEqualTo(field: string, value: ValueType): DataAbilityPredicates
522
523Sets a **DataAbilityPredicates** object to match the field with data type **ValueType** and value greater than or equal to the specified value.
524
525**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
526
527**Parameters**
528
529| Name | Type | Mandatory | Description |
530| -------- | -------- | -------- | -------- |
531| field | string | Yes | Column name in the table. |
532| value | [ValueType](#valuetype) | Yes | Value to match the **DataAbilityPredicates**. |
533
534**Return value**
535
536| Type | Description |
537| -------- | -------- |
538| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
539
540**Example**
541
542  ```js
543  dataAbilityPredicates.greaterThanOrEqualTo("AGE", 18)
544  ```
545
546### lessThanOrEqualTo
547
548lessThanOrEqualTo(field: string, value: ValueType): DataAbilityPredicates
549
550Sets a **DataAbilityPredicates** object to match the field with data type **ValueType** and value less than or equal to the specified value.
551
552**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
553
554**Parameters**
555
556| Name | Type | Mandatory | Description |
557| -------- | -------- | -------- | -------- |
558| field | string | Yes | Column name in the table. |
559| value | [ValueType](#valuetype) | Yes | Value to match the **DataAbilityPredicates**. |
560
561**Return value**
562
563| Type | Description |
564| -------- | -------- |
565| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
566
567**Example**
568
569  ```js
570  dataAbilityPredicates.lessThanOrEqualTo("AGE", 20)
571  ```
572
573### orderByAsc
574
575orderByAsc(field: string): DataAbilityPredicates
576
577Sets a **DataAbilityPredicates** object to sort the data records in ascending order. When there are multiple **orderByAsc**s, the first **orderByAsc** used has the highest priority.
578
579**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
580
581**Parameters**
582
583| Name | Type | Mandatory | Description |
584| -------- | -------- | -------- | -------- |
585| field | string | Yes | Column name in the table. |
586
587**Return value**
588
589| Type | Description |
590| -------- | -------- |
591| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
592
593**Example**
594
595  ```js
596  // Sort data by name first; for the records with the same name, sort them by age; for the records with the same name and age, sort them by salary in ascending order.
597  dataAbilityPredicates.orderByAsc("NAME").orderByAsc("AGE").orderByAsc("SALARY")
598  ```
599
600### orderByDesc
601
602orderByDesc(field: string): DataAbilityPredicates
603
604Sets a **DataAbilityPredicates** object to sort the data records in descending order. When there are multiple **orderByDesc**s, the first **orderByDesc** used has the highest priority.
605
606**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
607
608**Parameters**
609
610| Name | Type | Mandatory | Description |
611| -------- | -------- | -------- | -------- |
612| field | string | Yes | Column name in the table. |
613
614**Return value**
615
616| Type | Description |
617| -------- | -------- |
618| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
619
620**Example**
621
622  ```js
623  // Sort the data by age first. For the data records with the same age, sort them by salary.
624  dataAbilityPredicates.orderByDesc("AGE").orderByDesc("SALARY")
625  ```
626
627### distinct
628
629distinct(): DataAbilityPredicates
630
631Sets a **DataAbilityPredicates** object to filter out duplicate records.
632
633**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
634
635**Return value**
636
637| Type | Description |
638| -------- | -------- |
639| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that can filter out duplicate records. |
640
641**Example**
642
643  ```js
644  dataAbilityPredicates.equalTo("NAME", "Rose").distinct()
645  ```
646
647### limitAs
648
649limitAs(value: number): DataAbilityPredicates
650
651Set a **DataAbilityPredicates** object to specify the maximum number of records.
652
653**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
654
655**Parameters**
656
657| Name | Type | Mandatory | Description |
658| -------- | -------- | -------- | -------- |
659| value | number | Yes | Maximum number of records. |
660
661**Return value**
662
663| Type | Description |
664| -------- | -------- |
665| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the maximum number of records. |
666
667**Example**
668
669  ```js
670  dataAbilityPredicates.equalTo("NAME", "Rose").limitAs(3)
671  ```
672
673### offsetAs
674
675offsetAs(rowOffset: number): DataAbilityPredicates
676
677Sets a **DataAbilityPredicates** object to specify the start position of the returned result. This API must be used with **limitAs**.
678
679**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
680
681**Parameters**
682
683| Name | Type | Mandatory | Description |
684| -------- | -------- | -------- | -------- |
685| rowOffset | number | Yes | Number of rows to offset from the beginning. The value is a positive integer. |
686
687**Return value**
688
689| Type | Description |
690| -------- | -------- |
691| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the start position of the returned result. |
692
693**Example**
694
695  ```js
696  // Display the three data records following the first three records.
697  dataAbilityPredicates.equalTo("NAME", "Rose").offsetAs(3).limitAs(3)
698  ```
699
700
701### groupBy
702
703groupBy(fields: Array<string>): DataAbilityPredicates
704
705Sets a **DataAbilityPredicates** object to group rows that have the same value into summary rows.
706
707**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
708
709**Parameters**
710
711| Name | Type | Mandatory | Description |
712| -------- | -------- | -------- | -------- |
713| fields | Array<string> | Yes | Names of columns to group. |
714
715**Return value**
716
717| Type | Description |
718| -------- | -------- |
719| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that groups rows with the same value. |
720
721**Example**
722
723  ```js
724  dataAbilityPredicates.groupBy(["AGE", "NAME"])
725  ```
726
727### indexedBy
728
729indexedBy(field: string): DataAbilityPredicates
730
731Sets a **DataAbilityPredicates** object to specify the index column. Before calling this API, you need to create an index column.
732
733**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
734
735**Parameters**
736
737| Name | Type | Mandatory | Description |
738| -------- | -------- | -------- | -------- |
739| field | string | Yes | Name of the index. |
740
741**Return value**
742
743| Type | Description |
744| -------- | -------- |
745| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the index column. |
746
747**Example**
748
749  ```js
750  import { dataAbility, relationalStore } from '@kit.ArkData';
751
752  let context = getContext(this);
753
754  const STORE_CONFIG : relationalStore.StoreConfig = {
755      name: 'RdbTest.db', // Database file name.
756      securityLevel: relationalStore.SecurityLevel.S3,
757  };
758  // Table structure: EMPLOYEE (NAME, AGE, SALARY, CODES)
759  const SQL_CREATE_TABLE = 'CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)'; // SQL statement for creating a data table.
760  relationalStore.getRdbStore(context, STORE_CONFIG, async (err, store) => {
761    if (err) {
762      console.error(`Failed to get RdbStore. Code:${err.code}, message:${err.message}`);
763      return;
764    }
765    console.info('Succeeded in getting RdbStore.');
766
767
768    await store.executeSql(SQL_CREATE_TABLE); // Create a data table.
769
770
771    // Create an index.
772    const SQL_CREATE_INDEX = 'CREATE INDEX SALARY_INDEX ON EMPLOYEE(SALARY)'
773    await store.executeSql(SQL_CREATE_INDEX);
774    // ...
775
776    let dataAbilityPredicates = new dataAbility.DataAbilityPredicates()
777    dataAbilityPredicates.indexedBy("SALARY_INDEX")
778
779    //  ...
780  })
781  ```
782
783### in
784
785in(field: string, value: Array<ValueType>): DataAbilityPredicates
786
787Sets a **DataAbilityPredicates** object to match the field with data type Array\<ValueType> and value within the specified range.
788
789**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
790
791**Parameters**
792
793| Name | Type | Mandatory | Description |
794| -------- | -------- | -------- | -------- |
795| field | string | Yes | Column name in the table. |
796| value | Array&lt;[ValueType](#valuetype)&gt; | Yes | Array of **ValueType**s to match. |
797
798
799**Return value**
800
801| Type | Description |
802| -------- | -------- |
803| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
804
805**Example**
806
807  ```js
808  dataAbilityPredicates.in("AGE", [18, 20])
809  ```
810
811### notIn
812
813notIn(field: string, value: Array&lt;ValueType&gt;): DataAbilityPredicates
814
815Sets a **DataAbilityPredicates** object to match the field with data type Array\<ValueType> and value out of the specified range.
816
817**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
818
819**Parameters**
820
821| Name | Type | Mandatory | Description |
822| -------- | -------- | -------- | -------- |
823| field | string | Yes | Column name in the table. |
824| value | Array&lt;[ValueType](#valuetype)&gt; | Yes | Array of **ValueType**s to match. |
825
826**Return value**
827
828| Type | Description |
829| -------- | -------- |
830| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field. |
831
832**Example**
833
834  ```js
835  dataAbilityPredicates.notIn("NAME", ["Lisa", "Rose"])
836  ```
837
838## ValueType
839
840type ValueType = number | string | boolean
841
842Enumerates the value types.
843
844**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
845
846| Type   | Description                |
847| ------- | -------------------- |
848| number  | The value is a number.  |
849| string  | The value is a string.  |
850| boolean | The value is of Boolean type. |
851