1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit ArkData
19 */
20
21import { ValueType } from './@ohos.data.ValuesBucket';
22
23/**
24 * This module provides data share services based on the ExtensionAbility.
25 *
26 * @namespace dataSharePredicates
27 * @syscap SystemCapability.DistributedDataManager.DataShare.Core
28 * @StageModelOnly
29 * @since 10
30 */
31/**
32 * This module provides data share services based on the ExtensionAbility.
33 *
34 * @namespace dataSharePredicates
35 * @syscap SystemCapability.DistributedDataManager.DataShare.Core
36 * @StageModelOnly
37 * @crossplatform
38 * @since 12
39 */
40declare namespace dataSharePredicates {
41  /**
42   * Manages relational database configurations.
43   *
44   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
45   * @StageModelOnly
46   * @since 10
47   */
48  /**
49   * Manages relational database configurations.
50   *
51   * @syscap SystemCapability.DistributedDataManager.DataShare.Core
52   * @StageModelOnly
53   * @crossplatform
54   * @since 12
55   */
56  class DataSharePredicates {
57    /**
58     * Configure the DataSharePredicates to match the field whose data type is ValueType and value is equal
59     * to a specified value.
60     * This method is similar to = of the SQL statement.
61     *
62     * @param { string } field - Indicates the column name in the database table.
63     * @param { ValueType } value - Indicates the value to match with the DataSharePredicates.
64     * @returns { DataSharePredicates } Returns the DataSharePredicates that match the specified field.
65     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
66     * @StageModelOnly
67     * @since 10
68     */
69    /**
70     * Configure the DataSharePredicates to match the field whose data type is ValueType and value is equal
71     * to a specified value.
72     * This method is similar to = of the SQL statement.
73     *
74     * @param { string } field - Indicates the column name in the database table.
75     * @param { ValueType } value - Indicates the value to match with the DataSharePredicates.
76     * @returns { DataSharePredicates } Returns the DataSharePredicates that match the specified field.
77     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
78     * @StageModelOnly
79     * @crossplatform
80     * @since 12
81     */
82    equalTo(field: string, value: ValueType): DataSharePredicates;
83
84    /**
85     * Configure the DataSharePredicates to match the field whose data type is ValueType and value is unequal to
86     * a specified value.
87     * This method is similar to != of the SQL statement.
88     *
89     * @param { string } field - Indicates the column name in the database table.
90     * @param { ValueType } value - Indicates the value to match with the DataSharePredicates.
91     * @returns { DataSharePredicates } Returns the DataSharePredicates that match the specified field.
92     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
93     * @systemapi
94     * @StageModelOnly
95     * @since 9
96     */
97    notEqualTo(field: string, value: ValueType): DataSharePredicates;
98
99    /**
100     * Adds a left parenthesis to the DataSharePredicates.
101     * This method is similar to ( of the SQL statement and needs to be used together with endWrap().
102     *
103     * @returns { DataSharePredicates } Returns the DataSharePredicates with the left parenthesis.
104     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
105     * @systemapi
106     * @StageModelOnly
107     * @since 9
108     */
109    beginWrap(): DataSharePredicates;
110
111    /**
112     * Adds a right parenthesis to the DataSharePredicates.
113     * This method is similar to ) of the SQL statement and needs to be used together
114     * with beginWrap().
115     *
116     * @returns { DataSharePredicates } Returns the DataSharePredicates with the right parenthesis.
117     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
118     * @systemapi
119     * @StageModelOnly
120     * @since 9
121     */
122    endWrap(): DataSharePredicates;
123
124    /**
125     * Adds an or condition to the DataSharePredicates.
126     * This method is similar to or of the SQL statement.
127     *
128     * @returns { DataSharePredicates } Returns the DataSharePredicates with the or condition.
129     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
130     * @systemapi
131     * @StageModelOnly
132     * @since 9
133     */
134    or(): DataSharePredicates;
135
136    /**
137     * Adds an and condition to the DataSharePredicates.
138     * This method is similar to and of the SQL statement.
139     *
140     * @returns { DataSharePredicates } Returns the DataSharePredicates with the and condition.
141     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
142     * @StageModelOnly
143     * @since 10
144     */
145    /**
146     * Adds an and condition to the DataSharePredicates.
147     * This method is similar to and of the SQL statement.
148     *
149     * @returns { DataSharePredicates } Returns the DataSharePredicates with the and condition.
150     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
151     * @StageModelOnly
152     * @crossplatform
153     * @since 12
154     */
155    and(): DataSharePredicates;
156
157    /**
158     * Configure the DataSharePredicates to match the field whose data type is string and value
159     * contains a specified value.
160     * This method is similar to contains of the SQL statement.
161     *
162     * @param { string } field - Indicates the column name in the database table.
163     * @param { string } value - Indicates the value to match with the DataSharePredicates.
164     * @returns { DataSharePredicates } Returns the DataSharePredicates that match the specified field.
165     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
166     * @systemapi
167     * @StageModelOnly
168     * @since 9
169     */
170    contains(field: string, value: string): DataSharePredicates;
171
172    /**
173     * Configure the DataSharePredicates to match the field whose data type is string and value starts
174     * with a specified string.
175     * This method is similar to value% of the SQL statement.
176     *
177     * @param { string } field - Indicates the column name in the database table.
178     * @param { string } value - Indicates the value to match with the DataSharePredicates.
179     * @returns { DataSharePredicates } Returns the DataSharePredicates that match the specified field.
180     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
181     * @systemapi
182     * @StageModelOnly
183     * @since 9
184     */
185    beginsWith(field: string, value: string): DataSharePredicates;
186
187    /**
188     * Configure the DataSharePredicates to match the field whose data type is string and value
189     * ends with a specified string.
190     * This method is similar to %value of the SQL statement.
191     *
192     * @param { string } field - Indicates the column name in the database table.
193     * @param { string } value - Indicates the value to match with the DataSharePredicates.
194     * @returns { DataSharePredicates } Returns the DataSharePredicates that match the specified field.
195     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
196     * @systemapi
197     * @StageModelOnly
198     * @since 9
199     */
200    endsWith(field: string, value: string): DataSharePredicates;
201
202    /**
203     * Configure the DataSharePredicates to match the fields whose value is null.
204     * This method is similar to is null of the SQL statement.
205     *
206     * @param { string } field - Indicates the column name in the database table.
207     * @returns { DataSharePredicates } Returns the DataSharePredicates that match the specified field.
208     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
209     * @systemapi
210     * @StageModelOnly
211     * @since 9
212     */
213    isNull(field: string): DataSharePredicates;
214
215    /**
216     * Configure the DataSharePredicates to match the specified fields whose value is not null.
217     * This method is similar to is not null of the SQL statement.
218     *
219     * @param { string } field - Indicates the column name in the database table.
220     * @returns { DataSharePredicates } Returns the DataSharePredicates that match the specified field.
221     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
222     * @systemapi
223     * @StageModelOnly
224     * @since 9
225     */
226    isNotNull(field: string): DataSharePredicates;
227
228    /**
229     * Configure the DataSharePredicates to match the fields whose data type is string and value is
230     * similar to a specified string.
231     * This method is similar to like of the SQL statement.
232     *
233     * @param { string } field - Indicates the column name in the database table.
234     * @param { string } value - Indicates the value to match with the DataSharePredicates. The percent sign (%) in the value
235     * is a wildcard (like * in a regular expression).
236     * @returns { DataSharePredicates } Returns the DataSharePredicates that match the specified field.
237     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
238     * @systemapi
239     * @StageModelOnly
240     * @since 9
241     */
242    like(field: string, value: string): DataSharePredicates;
243
244    /**
245     * Configure the DataSharePredicates to match the fields whose data type is string and value is
246     * not similar to a specified string.
247     * This method is similar to unlike of the SQL statement.
248     *
249     * @param { string } field - Indicates the column name in the database table.
250     * @param { string } value - Indicates the value to match with the DataSharePredicates. The percent sign (%) in the value
251     * is a wildcard (like * in a regular expression).
252     * @returns { DataSharePredicates } Returns the DataSharePredicates that match the specified field.
253     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
254     * @systemapi
255     * @StageModelOnly
256     * @since 9
257     */
258    unlike(field: string, value: string): DataSharePredicates;
259
260    /**
261     * Configure DataSharePredicates to match the specified field whose data type is string and the value contains
262     * a wildcard.
263     * Different from like, the input parameters of this method are case-sensitive.
264     *
265     * @param { string } field - Indicates the column name in the database table.
266     * @param { string } value - Indicates the value to match with DataSharePredicates.
267     * @returns { DataSharePredicates } Returns the SQL statement with the specified DataSharePredicates.
268     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
269     * @systemapi
270     * @StageModelOnly
271     * @since 9
272     */
273    glob(field: string, value: string): DataSharePredicates;
274
275    /**
276     * Restricts the value of the field to the range between low value and high value.
277     *
278     * @param { string } field - Indicates the column name.
279     * @param { ValueType } low - Indicates the minimum value.
280     * @param { ValueType } high - Indicates the maximum value.
281     * @returns { DataSharePredicates } Returns the SQL query statement with the specified DataSharePredicates.
282     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
283     * @systemapi
284     * @StageModelOnly
285     * @since 9
286     */
287    between(field: string, low: ValueType, high: ValueType): DataSharePredicates;
288
289    /**
290     * Configure DataSharePredicates to match the specified field whose data type is int and value is
291     * out of a given range.
292     *
293     * @param { string } field - Indicates the column name in the database table.
294     * @param { ValueType } low - Indicates the minimum value to match with DataSharePredicates.
295     * @param { ValueType } high - Indicates the maximum value to match with DataSharePredicates.
296     * @returns { DataSharePredicates } Returns the SQL query statement with the specified DataSharePredicates.
297     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
298     * @systemapi
299     * @StageModelOnly
300     * @since 9
301     */
302    notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates;
303
304    /**
305     * Restricts the value of the field to be greater than the specified value.
306     *
307     * @param { string } field - Indicates the column name.
308     * @param { ValueType } value - Indicates the String field.
309     * @returns { DataSharePredicates } Returns the SQL query statement with the specified DataSharePredicates.
310     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
311     * @systemapi
312     * @StageModelOnly
313     * @since 9
314     */
315    greaterThan(field: string, value: ValueType): DataSharePredicates;
316
317    /**
318     * Restricts the value of the field to be smaller than the specified value.
319     *
320     * @param { string } field - Indicates the column name.
321     * @param { ValueType } value - Indicates the String field.
322     * @returns { DataSharePredicates } Returns the SQL query statement with the specified DataSharePredicates.
323     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
324     * @systemapi
325     * @StageModelOnly
326     * @since 9
327     */
328    lessThan(field: string, value: ValueType): DataSharePredicates;
329
330    /**
331     * Restricts the value of the field to be greater than or equal to the specified value.
332     *
333     * @param { string } field - Indicates the column name.
334     * @param { ValueType } value - Indicates the String field.
335     * @returns { DataSharePredicates } Returns the SQL query statement with the specified DataSharePredicates.
336     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
337     * @systemapi
338     * @StageModelOnly
339     * @since 9
340     */
341    greaterThanOrEqualTo(field: string, value: ValueType): DataSharePredicates;
342
343    /**
344     * Restricts the value of the field to be smaller than or equal to the specified value.
345     *
346     * @param { string } field - Indicates the column name.
347     * @param { ValueType } value - Indicates the String field.
348     * @returns { DataSharePredicates } Returns the SQL query statement with the specified DataSharePredicates.
349     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
350     * @systemapi
351     * @StageModelOnly
352     * @since 9
353     */
354    lessThanOrEqualTo(field: string, value: ValueType): DataSharePredicates;
355
356    /**
357     * Restricts the ascending order of the return list. When there are several orders,
358     * the one close to the head has the highest priority.
359     *
360     * @param { string } field - Indicates the column name for sorting the return list.
361     * @returns { DataSharePredicates } Returns the SQL query statement with the specified DataSharePredicates.
362     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
363     * @StageModelOnly
364     * @since 10
365     */
366    /**
367     * Restricts the ascending order of the return list. When there are several orders,
368     * the one close to the head has the highest priority.
369     *
370     * @param { string } field - Indicates the column name for sorting the return list.
371     * @returns { DataSharePredicates } Returns the SQL query statement with the specified DataSharePredicates.
372     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
373     * @StageModelOnly
374     * @crossplatform
375     * @since 12
376     */
377    orderByAsc(field: string): DataSharePredicates;
378
379    /**
380     * Restricts the descending order of the return list. When there are several orders,
381     * the one close to the head has the highest priority.
382     *
383     * @param { string } field - Indicates the column name for sorting the return list.
384     * @returns { DataSharePredicates } Returns the SQL query statement with the specified DataSharePredicates.
385     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
386     * @StageModelOnly
387     * @since 10
388     */
389    /**
390     * Restricts the descending order of the return list. When there are several orders,
391     * the one close to the head has the highest priority.
392     *
393     * @param { string } field - Indicates the column name for sorting the return list.
394     * @returns { DataSharePredicates } Returns the SQL query statement with the specified DataSharePredicates.
395     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
396     * @StageModelOnly
397     * @crossplatform
398     * @since 12
399     */
400    orderByDesc(field: string): DataSharePredicates;
401
402    /**
403     * Restricts each row of the query result to be unique.
404     *
405     * @returns { DataSharePredicates } Returns the SQL query statement with the specified DataSharePredicates.
406     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
407     * @systemapi
408     * @StageModelOnly
409     * @since 9
410     */
411    distinct(): DataSharePredicates;
412
413    /**
414     * Construct a query object to specify the number of results and the starting position.
415     *
416     * @param { number } total - Represents the specified number of results.
417     * @param { number } offset - Indicates the starting position.
418     * @returns { DataSharePredicates } Returns the query object.
419     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
420     * @StageModelOnly
421     * @since 10
422     */
423    /**
424     * Construct a query object to specify the number of results and the starting position.
425     *
426     * @param { number } total - Represents the specified number of results.
427     * @param { number } offset - Indicates the starting position.
428     * @returns { DataSharePredicates } Returns the query object.
429     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
430     * @StageModelOnly
431     * @crossplatform
432     * @since 12
433     */
434    limit(total: number, offset: number): DataSharePredicates;
435
436    /**
437     * Configure {@code DataSharePredicates} to group query results by specified columns.
438     *
439     * @param { Array<string> } fields - Indicates the specified columns by which query results are grouped.
440     * @returns { DataSharePredicates } Returns the DataSharePredicates with the specified columns by which query results are grouped.
441     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
442     * @systemapi
443     * @StageModelOnly
444     * @since 9
445     */
446    groupBy(fields: Array<string>): DataSharePredicates;
447
448    /**
449     * Configure {@code DataSharePredicates} to specify the index column.
450     * Before using this method, you need to create an index column.
451     *
452     * @param { string } field - Indicates the name of the index column.
453     * @returns { DataSharePredicates } Returns DataSharePredicates with the specified index column.
454     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
455     * @systemapi
456     * @StageModelOnly
457     * @since 9
458     */
459    indexedBy(field: string): DataSharePredicates;
460
461    /**
462     * Configure {@code DataSharePredicates} to match the specified field whose data type is ValueType array and values
463     * are within a given range.
464     *
465     * @param { string } field - Indicates the column name in the database table.
466     * @param { Array<ValueType> } value - Indicates the values to match with DataSharePredicates.
467     * @returns { DataSharePredicates } Returns DataSharePredicates that matches the specified field.
468     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
469     * @StageModelOnly
470     * @since 10
471     */
472    /**
473     * Configure {@code DataSharePredicates} to match the specified field whose data type is ValueType array and values
474     * are within a given range.
475     *
476     * @param { string } field - Indicates the column name in the database table.
477     * @param { Array<ValueType> } value - Indicates the values to match with DataSharePredicates.
478     * @returns { DataSharePredicates } Returns DataSharePredicates that matches the specified field.
479     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
480     * @StageModelOnly
481     * @crossplatform
482     * @since 12
483     */
484    in(field: string, value: Array<ValueType>): DataSharePredicates;
485
486    /**
487     * Configure {@code DataSharePredicates} to match the specified field whose data type is String array and values
488     * are out of a given range.
489     *
490     * @param { string } field - Indicates the column name in the database table.
491     * @param { Array<ValueType> } value - Indicates the values to match with DataSharePredicates.
492     * @returns { DataSharePredicates } Returns DataSharePredicates that matches the specified field.
493     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
494     * @systemapi
495     * @StageModelOnly
496     * @since 9
497     */
498    notIn(field: string, value: Array<ValueType>): DataSharePredicates;
499
500    /**
501     * Configure {@code DataSharePredicates} Creates a query condition using the specified key prefix.
502     *
503     * @param { string } prefix - Represents the specified key prefix.
504     * @returns { DataSharePredicates } Returns the query object.
505     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
506     * @systemapi
507     * @StageModelOnly
508     * @since 9
509     */
510    prefixKey(prefix: string): DataSharePredicates;
511
512    /**
513     * Configure {@code DataSharePredicates} to match the specified value whose key is within a given range.
514     *
515     * @param { Array<string> } keys - Represents the key names.
516     * @returns { DataSharePredicates } Returns the query object.
517     * @syscap SystemCapability.DistributedDataManager.DataShare.Core
518     * @systemapi
519     * @StageModelOnly
520     * @since 9
521     */
522    inKeys(keys: Array<string>): DataSharePredicates;
523  }
524}
525
526export default dataSharePredicates;
527