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