@wix/wix-data-items-common 1.0.162 → 1.0.164
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../src/api/WixDataSearch.ts"],"sourcesContent":["import { WixDataResult } from './WixDataResult'\nimport { WixDataReadOptions } from './types'\nimport { WixDataFilter } from './WixDataFilter'\n\n/**\n * @builder\n * Represents a search operation to be performed on a Wix Data collection.\n * Allows for building complex search requests by specifying search expressions, modes, filters, sorting, and pagination.\n */\nexport interface WixDataSearch {\n /**\n * Specifies the text to search for in the collection.\n *\n * The `expression()` method sets the search query. Search terms are separated by whitespace.\n *\n * @param queryText - Text to search for in the collection.\n * @returns Refined WixDataSearch object.\n */\n expression(queryText: string): WixDataSearch\n\n /**\n * Enables fuzzy search for approximate text matching.\n *\n * The `fuzzy()` method enables fuzzy search. This allows for approximate matches that closely resemble the search expression even if they don't match exactly.\n *\n * @returns Refined WixDataSearch object.\n */\n fuzzy(): WixDataSearch\n\n /**\n * Sets the search mode to **AND** for expression terms.\n *\n * When in **AND** mode, an item must include all specified search terms, and meet all filter conditions, to be included in the results. For example, the search expression \"red car\" in **AND** mode only retrieves items that include both \"red\" and \"car\".\n *\n * @returns Refined WixDataSearch object.\n */\n andMode(): WixDataSearch\n\n /**\n * Sets the search mode to **OR** for expression terms.\n *\n * When in **OR** mode, an item must include at least one of the specified search terms to be included in the results. For example, the search expression \"red car\" in **OR** mode retrieves items that include \"red\", \"car\", or both.\n *\n * @returns Refined WixDataSearch object.\n */\n orMode(): WixDataSearch\n\n /**\n * Runs the search operation.\n *\n * The `run()` method searches the collection for the specified expression. It returns a Promise that resolves to a `WixDataResult` that contains the matching items and search metadata.\n *\n * Search operations are [eventually consistent](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency) and may not reflect recent changes.\n * @param options - Configuration options for building the search operation.\n * @returns Promise that resolves to a WixDataResult containing the matching items and search metadata.\n */\n run(options?: WixDataReadOptions): Promise<WixDataResult>\n\n /**\n * Sorts search results by the specified fields in descending order.\n *\n * The `descending()` method refines the search to sort results in descending order of the specified fields.\n * If you specify more than one field, `descending()` sorts the results in descending order by each field in the order they are listed.\n *\n * You can sort the following types:\n * - **Number**: Sorts numerically.\n * - **Date**: Sorts by date and time.\n * - **String**: Sorts lexicographically, so `\"abc\"` comes before `\"XYZ\"`.\n * - **Reference**: Compares by the ID of the referenced item as a String.\n *\n * If a field contains a number as a String, that value is sorted alphabetically and not numerically.\n * Items that do not have a value for the specified sort field are ranked lowest.\n *\n * @public\n * @documentationMaturity preview\n * @param fields - Fields by which to sort results in descending order.\n * @requiredField fields\n * @returns Refined WixDataSearch object.\n */\n descending(...fields: string[]): WixDataSearch\n /**\n * @param fields - Array of fields to sort by in descending order.\n * @returns Refined WixDataSearch object.\n */\n descending(fields: string[]): WixDataSearch\n /**\n * @param fields - Fields used in the sort.\n * @returns Refined WixDataSearch object.\n */\n descending(...fields: any): WixDataSearch\n\n /**\n * Sorts search results by the specified fields in ascending order.\n *\n * The `ascending()` method refines the search to sort results in ascending order of the specified fields.\n * If you specify more than one field, `ascending()` sorts the results in ascending order by each field in the order they are listed.\n *\n * You can sort the following types:\n * - **Number**: Sorts numerically.\n * - **Date**: Sorts by date and time.\n * - **String**: Sorts lexicographically, so `\"abc\"` comes before `\"XYZ\"`.\n * - **Reference**: Compares by the ID of the referenced item as a String.\n *\n * If a field contains a number as a String, that value is sorted alphabetically and not numerically.\n * Items that do not have a value for the specified sort field are ranked lowest.\n *\n * @public\n * @documentationMaturity preview\n * @param fields - Fields by which to sort results in ascending order.\n * @requiredField fields\n * @returns Refined WixDataSearch object.\n */\n ascending(...fields: string[]): WixDataSearch\n /**\n * @param fields - Array of fields to sort by in ascending order.\n * @returns Refined WixDataSearch object.\n */\n ascending(fields: string[]): WixDataSearch\n /**\n * @param fields - Fields used in the sort.\n * @returns Refined WixDataSearch object.\n */\n ascending(...fields: any): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value equals the specified value.\n *\n * The `eq()` method refines the search to only match items where the value of the specified field equals the specified `value`. It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.\n *\n * Matching strings with `eq()` is case-sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the field contains an array, `eq()` matches the item if at least one array element equals the specified `value`.\n *\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `value`.\n * @requiredField field\n * @param value - Value to match.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n eq(field: string, value: any): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value does not equal the specified value.\n *\n * The `ne()` method refines this search to only\n * match items where the value of the specified field does not equal the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type is considered not equal to the same number stored as a Number type.\n *\n * Matching strings with `ne()` is case-sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the value of `field` is an array, `ne()` includes items in which none of the elements of the array match the specified `value`.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `value`.\n * @requiredField field\n * @param value - Value to not match.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n ne(field: string, value: any): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value is greater than or equal to the specified\n * value.\n *\n * The `ge()` method refines this search to only\n * match items where the value of the specified field is greater than or\n * equal to the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * If a field contains a number as a String, that value is compared\n * alphabetically and not numerically. Items that do not have a value for the\n * specified field are ranked lowest.\n *\n * The following types of fields can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically,\n * so `\"abc\"` is greater than or equal to `\"ABC\"` (because of the greater than),\n * but `\"ABC\"` is not greater than or equal to `\"abc\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `value`.\n * @requiredField field\n * @param value - Value to compare against.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n ge(field: string, value: string | number | Date): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value is greater than the specified value.\n *\n * The `gt()` method refines this search to only match items where the value of the specified field is greater than the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.\n *\n * If a field contains a number as a String, that value is compared alphabetically and not numerically. Items that do not have a value for the specified field are ranked lowest.\n *\n * The following types of fields can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so `\"text\"` is greater than `\"Text\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - field whose value is compared with `value`.\n * @requiredField field\n * @param value - Value to compare against.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n gt(field: string, value: string | number | Date): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value is less than or equal to the specified\n * value.\n *\n * The `le()` method refines this search to only match\n * items where the value of the specified field is less than or equal to the\n * specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * If a field contains a number as a String, that value is compared\n * alphabetically and not numerically. Items that do not have a value for the\n * specified field are ranked lowest.\n *\n * The following types of fields can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically,\n * so `\"ABC\"` is less than or equal to `\"abc\"` (because of the less than),\n * but `\"abc\"` is not less than or equal to `\"ABC\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `value`.\n * @requiredField field\n * @param value - Value to compare against.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n le(field: string, value: string | number | Date): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value is less than the specified value.\n *\n * The `lt()` method refines this search to only match\n * items where the value of the specified field is less than the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * If a field contains a number as a String, that value is compared\n * alphabetically and not numerically. Items that do not have a value for the\n * specified field are ranked lowest.\n *\n * The following types of fields can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so `\"Text\"` is less than `\"text\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `value`.\n * @requiredField field\n * @param value - Value to compare against.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n lt(field: string, value: string | number | Date): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field has any value (is not null or undefined).\n *\n * The `isNotEmpty()` method refines this search to only match items where the\n * value of the specified field is not `null` or `undefined`.\n *\n * If the field contains any value at all for a given item, including the\n * empty string or an invalid value, that item will match the search filter.\n * @public\n * @documentationMaturity preview\n * @param field - Field in which to check for a non-empty value.\n * @requiredField field\n * @returns Refined WixDataSearch object.\n */\n isNotEmpty(field: string): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field does not exist or does not have any value (is null or undefined).\n *\n * The `isEmpty()` method refines this search to only match items where the\n * value of the specified field is `null` or `undefined` or the field does\n * not exist.\n *\n * If the field contains any value at all for a given item, including the\n * empty string or an invalid value, that item will not match the search filter.\n * @public\n * @documentationMaturity preview\n * @param field - Field in which to check for an empty or non-existent value.\n * @requiredField field\n * @returns Refined WixDataSearch object.\n */\n isEmpty(field: string): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value starts with a specified string.\n *\n * The `startsWith()` method refines this search to only match items where the value of the specified field starts with the specified `string`. Matching with `startsWith()` is case-sensitive, so searching for `\"Sun\"` does not retrieve an item that contains the text `\"sunshine\"`.\n *\n * You can only use `startsWith()` with a field whose value is a String or Reference.\n * When using a Reference, `startsWith()` matches by the ID of the referenced item as Strings.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with the `value` parameter.\n * @requiredField field\n * @param value - String to look for at the beginning of the specified field value.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n startsWith(field: string, value: string): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value equals any of the specified values.\n *\n * The `hasSome()` method refines the search to only match items where the value of the specified field equals any of the specified values.\n *\n * Matching strings with `hasSome()` is case-sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the specified field contains an array, `hasSome()` matches if any of the elements in that array match any of the specified values.\n *\n * If the specified field contains multiple references, pass item IDs as the values. `hasSome()` matches if any of the multiple references match any of the specified ID values.\n *\n * You can specify multiple values to match by providing an array of String, Number, or Date types as the `values` parameters.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `values`.\n * @requiredField field\n * @param values - Values to match.\n * @requiredField values\n * @returns Refined WixDataSearch object.\n */\n hasSome(field: string, ...values: string[] | number[] | Date[]): WixDataSearch\n\n /**\n * Overload for `hasSome()`. Refines a search to match items whose specified field value equals any of the specified values.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with the provided values.\n * @requiredField field\n * @param values - An array of values to match.\n * @requiredField values\n * @returns Refined WixDataSearch object.\n */\n hasSome(field: string, values: string[] | number[] | Date[]): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value equals all of the specified values.\n *\n * The `hasAll()` method refines this search to\n * only match items where the value of the specified field equals all of\n * the specified values.\n *\n * Matching strings with `hasAll()` is case-sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the value of the specified field is an array, `hasAll()` will match\n * if there is a match in the elements of that array for all of the specified\n * values.\n *\n * You can specify a list of values to match by providing an array of\n * String, Number, or Date types as the `values` parameters.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `values`.\n * @requiredField field\n * @param values - Values to match. All specified values must be present.\n * @requiredField values\n * @returns Refined WixDataSearch object.\n */\n hasAll(field: string, ...values: string[] | number[] | Date[]): WixDataSearch\n\n /**\n * Overload for `hasAll()`. Refines a search to match items whose specified field values equals all of the specified values.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with the provided values.\n * @requiredField field\n * @param values - Array of values to match. All values in the array must be present.\n * @requiredField values\n * @returns Refined WixDataSearch object.\n */\n hasAll(field: string, values: string[] | number[] | Date[]): WixDataSearch\n\n /**\n * Adds an `or` condition to the search filter.\n *\n * The `or()` method adds an inclusive `or` condition to this search filter. The search returns all the items that match the filter as defined up to the `or()` method, the items that match the filter passed to the `or()` method, and the items that match both.\n *\n * > **Note**: The `or()` method is designed to work with 2 or more filters. Used on its own, it might produce unexpected results.\n * @public\n * @documentationMaturity preview\n * @param filter - Filter to add to the initial filter as an `or` condition.\n * @requiredField filter\n * @returns Refined WixDataSearch object.\n */\n or(filter: WixDataFilter): WixDataSearch\n\n /**\n * Adds an `and` condition to the search filter.\n *\n * The `and()` method adds an `and` condition to the search filter. A search with an `and` returns all the items that match the filter as defined up to the `and()` method, as well as the filter passed to the `and()` method.\n *\n * When chaining multiple filter methods to a search, an `and` condition is often assumed by default. For example, this search returns results whose status is active **and** age is greater than 25:\n *\n * ```javascript\n * items.search(\"myCollection\").expression(\"some text\").eq(\"status\", \"active\").gt(\"age\", 25);\n * ```\n *\n * The `and()` method is needed when performing compound filters. For example, the final search in this set of operations returns results whose status is either pending or rejected **and** age is either less than 25 or greater than 65:\n *\n * ```javascript\n * let statusFilter = items.filter().eq(\"status\", \"pending\").or(items.filter().eq(\"status\", \"rejected\"));\n *\n * let ageFilter = items.filter().lt(\"age\", 25).or(items.filter().gt(\"age\", 65));\n *\n * let finalSearch = items.search(\"myCollection\").expression(\"some text\").and(statusFilter).and(ageFilter);\n * ```\n *\n * > **Note**: The `and()` method is designed to work with 2 or more filters.\n *\n * @public\n * @documentationMaturity preview\n * @param filter - Filter to add to the initial search filter as an `and` condition.\n * @requiredField filter\n * @returns Refined WixDataSearch object.\n */\n and(filter: WixDataFilter): WixDataSearch\n\n /**\n * Adds a `not` condition to the search filter.\n *\n * The `not()` method adds a `not` condition to the search filter. A search with a `not` returns all the items that match the filter as defined up to the `not()` method and don't match the filter passed to the `not()` method.\n *\n * If the search filter only contains a `not()` method, it returns all the items that don't match the filter specified to the method.\n *\n * @public\n * @documentationMaturity preview\n * @param filter - Filter to add to the initial filter as a `not` condition.\n * @requiredField filter\n * @returns Refined WixDataSearch object.\n */\n not(filter: WixDataFilter): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value is within a specified range.\n *\n * The `between()` method refines this search to only match items where the value of the specified field is\n * greater than or equal to `rangeStart` and less than `rangeEnd`.\n *\n * It only matches values of the same type. For example, a number value stored as a String type does not match the\n * same number stored as a Number type.\n *\n * If a field contains a number as a String, that value is compared alphabetically and not numerically. Items\n * that do not have a value for the specified field are ranked lowest.\n *\n * The following types of fields can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so\n * - `\"A\"` and `\"M\"` are between `\"A\"` and `\"Z\"`, but `\"a\"`, `\"m\"`, `\"z\"` and `\"Z\"` are not.\n * - `\"A\"`, `\"M\"`, `\"Z\"`, and `\"a\"` are between `\"A\"` and `\"z\"`, but `\"z\"` is not.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with rangeStart and rangeEnd.\n * @requiredField field\n * @param rangeStart - Starting value of the range to match (inclusive).\n * @requiredField rangeStart\n * @param rangeEnd - Ending value of the range to match (exclusive).\n * @requiredField rangeEnd\n * @returns Refined WixDataSearch object.\n */\n between(\n field: string,\n rangeStart: string | number | Date,\n rangeEnd: string | number | Date\n ): WixDataSearch\n\n /**\n * Lists the fields to return in a search's results.\n *\n * The `fields()` method specifies which fields to return in the search results.\n *\n * You can use `include()` in conjunction with `fields()` to get referenced items.\n *\n * When `fields()` receives an empty or invalid field, the search behaves as follows:\n * - When no fields are specified, the search returns all fields.\n * - When multiple fields are specified but some are invalid, invalid fields are ignored and valid fields are returned.\n * - When only invalid fields are specified, only the default `_id` field is returned.\n * @public\n * @documentationMaturity preview\n * @param fields - Fields to return.\n * @requiredField fields\n * @returns Refined WixDataSearch object.\n */\n fields(...fields: string[]): WixDataSearch\n\n /**\n * Limits the number of items the search returns.\n *\n * The `limit()` method defines the number of results a search returns in each\n * page. Only one page of results is retrieved at a time. The `next()`\n * and `prev()` methods of the `WixDataResult` object are used to\n * navigate the pages of a search result.\n *\n * By default, `limit` is set to `100`.\n *\n * The maximum value that `limit()` can accept is `1000`.\n *\n * @public\n * @documentationMaturity preview\n * @param limitNumber - Number of items to return, which is also the `pageSize` of the results object.\n * @requiredField limitNumber\n * @returns Refined WixDataSearch object.\n */\n limit(limitNumber: number): WixDataSearch\n\n /**\n * Sets the number of items to skip before returning search results.\n *\n * The `skip()` method defines the number of results to skip in the search\n * results before returning new search results.\n *\n * For example, if your search matches 50 items, but\n * you set `skip` to 10, the results returned will skip the first 10 items\n * that match and return the 11th through 50th items.\n *\n * By default, `skip` is set to 0.\n * @public\n * @documentationMaturity preview\n * @param skipCount - Number of items to skip in the search results before returning the results.\n * @requiredField skipCount\n * @returns Refined WixDataSearch object.\n */\n skip(skipCount: number): WixDataSearch\n\n /**\n * Includes referenced items for the specified fields in a search's results.\n *\n * The `include()` method refines a search so that the items returned in the\n * search's results include the full referenced items for the specified fields.\n *\n * For example, suppose you have a **books** collection with an **author** field that references an **authors** collection. Searching the **books** collection with an `include(\"author\")` returns the relevant book items and each item will include the full referenced author item in the book's `author` field.\n *\n * When searching a collection that contains a reference field without using the\n * `include()` method:\n * - Single reference field: returned items contain only the ID of the\n * referenced item, and not the full referenced items.\n * - Multiple reference field: returned items do not contain the multiple\n * reference field at all.\n *\n * When including a field with multiple references, the following limitations\n * apply:\n * - Only one field with multiple references can be included.\n * - The search will return an error if more than 50 items are returned, regardless\n * of any search limit set using the `limit()` method.\n * - Each returned item can include up to 50 referenced items. If there are more\n * than 50 referenced items, only 50 are returned when the search is run\n * and the `partialIncludes` field of the returned `WixDataResult` is `true`.\n *\n * > **Note:** The `include()` method is not supported for [single-item collections](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection).\n *\n * @public\n * @documentationMaturity preview\n * @param fields - Fields for which to include referenced items.\n * @requiredField fields\n * @returns Refined WixDataSearch object.\n */\n include(...fields: string[]): WixDataSearch\n\n /**\n * Overload for `include()`. Includes referenced items for the specified field in a search's results.\n * @public\n * @documentationMaturity preview\n * @param field - Field for which to include referenced items.\n * @param limit - Optional limit for the number of referenced items to include (behavior may vary).\n * @returns Refined WixDataSearch object.\n */\n include(field: string, limit?: number): WixDataSearch\n\n /**\n * Overload for `include()`. Includes referenced items for the specified fields in a search's results.\n * @public\n * @documentationMaturity preview\n * @param field1 - First field for which to include referenced items.\n * @param field2 - Second field for which to include referenced items.\n * @param limit - Optional limit for the number of referenced items to include (behavior may vary).\n * @returns Refined WixDataSearch object.\n */\n include(field1: string, field2: string, limit?: number): WixDataSearch\n\n /**\n * Overload for `include()`. Includes referenced items for the specified fields in a search's results.\n * @public\n * @documentationMaturity preview\n * @param field1 - First field.\n * @param field2 - Second field.\n * @param field3 - Third field.\n * @param limit - Optional limit.\n * @returns Refined WixDataSearch object.\n */\n include(\n field1: string,\n field2: string,\n field3: string,\n limit?: number\n ): WixDataSearch\n\n /**\n * Overload for `include()`. Includes referenced items for the specified fields in a search's results.\n * @public\n * @documentationMaturity preview\n * @param field1 - First field.\n * @param field2 - Second field.\n * @param field3 - Third field.\n * @param field4 - Fourth field.\n * @param limit - Optional limit.\n * @returns Refined WixDataSearch object.\n */\n include(\n field1: string,\n field2: string,\n field3: string,\n field4: string,\n limit?: number\n ): WixDataSearch\n\n /**\n * Overload for `include()`. Includes referenced items for the specified fields in a search's results.\n * @public\n * @documentationMaturity preview\n * @param field1 - First field.\n * @param field2 - Second field.\n * @param field3 - Third field.\n * @param field4 - Fourth field.\n * @param field5 - Fifth field.\n * @param limit - Optional limit.\n * @returns Refined WixDataSearch object.\n */\n include(\n field1: string,\n field2: string,\n field3: string,\n field4: string,\n field5: string,\n limit?: number\n ): WixDataSearch\n\n /**\n * Overload for `include()`. Includes referenced items for the specified fields in a search's results.\n * Allows specifying multiple field names and an optional limit.\n * @public\n * @documentationMaturity preview\n * @param fieldNamesAndLimit - Array of field names, optionally followed by a limit number.\n * @returns Refined WixDataSearch object.\n */\n include(...fieldNamesAndLimit: [...string[], number]): WixDataSearch\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/api/WixDataSearch.ts"],"sourcesContent":["import { WixDataResult } from './WixDataResult'\nimport { WixDataReadOptions } from './types'\nimport { WixDataFilter } from './WixDataFilter'\n\n/**\n * @builder\n * Represents a search operation to be performed on a Wix Data collection.\n * Allows for building complex search requests by specifying search expressions, modes, filters, sorting, and pagination.\n */\nexport interface WixDataSearch {\n /**\n * Specifies the text to search in the collection.\n *\n * The `expression()` method sets the search query. Search terms are separated by whitespace.\n *\n * @param queryText - Text to search in the collection.\n * @returns Refined WixDataSearch object.\n */\n expression(queryText: string): WixDataSearch\n\n /**\n * Enables fuzzy search for approximate text matching.\n *\n * The `fuzzy()` method enables fuzzy search. This allows for approximate matches that closely resemble the search expression even if they don't exactly match.\n *\n * @returns Refined WixDataSearch object.\n */\n fuzzy(): WixDataSearch\n\n /**\n * Sets the search mode to **AND**.\n *\n * When in **AND** mode, an item must include all specified search terms to be included in the results. For example, the search expression \"red car\" in **AND** mode only retrieves items that include both \"red\" and \"car\".\n *\n * @returns Refined WixDataSearch object.\n */\n andMode(): WixDataSearch\n\n /**\n * Sets the search mode to **OR**.\n *\n * When in **OR** mode, an item must include at least one of the specified search terms to be included in the results. For example, the search expression \"red car\" in **OR** mode retrieves items that include \"red\", \"car\", or both.\n *\n * @returns Refined WixDataSearch object.\n */\n orMode(): WixDataSearch\n\n /**\n * Runs the search operation.\n *\n * The `run()` method searches the collection for the specified expression. It returns a Promise that resolves to a [`WixDataResult`](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-result/introduction) that contains the matching items and search metadata.\n *\n * Search operations are [eventually consistent](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency) and might not reflect recent changes.\n * @param options - Options for building the search operation.\n * @returns Promise that resolves to a [`WixDataResult`](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-result/introduction) containing the matching items and search metadata.\n */\n run(options?: WixDataReadOptions): Promise<WixDataResult>\n\n /**\n * Sorts search results by the specified fields in descending order.\n *\n * The `descending()` method refines the search to sort results by the specified fields in descending order. If you specify more than one field, `descending()` sorts the results in descending order by each field in the order they are listed.\n *\n * You can sort the following types:\n * - **Number**: Sorts numerically.\n * - **Date**: Sorts by date and time.\n * - **String**: Sorts lexicographically, so `\"abc\"` comes before `\"XYZ\"`.\n * - **Reference**: Compares by the ID of the referenced item as a String.\n *\n * If a field contains a number as a String, that value is sorted alphabetically and not numerically.\n * Items that do not have a value for the specified sort field are ranked lowest.\n *\n * @public\n * @documentationMaturity preview\n * @param fields - Fields by which to sort results in descending order.\n * @requiredField fields\n * @returns Refined WixDataSearch object.\n */\n descending(...fields: string[]): WixDataSearch\n /**\n * @param fields - Array of fields by which to sort results in descending order.\n * @returns Refined WixDataSearch object.\n */\n descending(fields: string[]): WixDataSearch\n /**\n * @param fields - Fields by which to sort results in descending order.\n * @returns Refined WixDataSearch object.\n */\n descending(...fields: any): WixDataSearch\n\n /**\n * Sorts search results in ascending order by the specified fields.\n *\n * The `ascending()` method refines the search to sort results by the specified fields in ascending order. If you specify more than one field, `ascending()` sorts the results in ascending order by each field in the order they are listed.\n *\n * You can sort the following types:\n * - **Number**: Sorts numerically.\n * - **Date**: Sorts by date and time.\n * - **String**: Sorts lexicographically, so `\"abc\"` comes before `\"XYZ\"`.\n * - **Reference**: Compares by the ID of the referenced item as a String.\n *\n * If a field contains a number as a String, that value is sorted alphabetically and not numerically.\n * Items that do not have a value for the specified sort field are ranked lowest.\n *\n * @public\n * @documentationMaturity preview\n * @param fields - Fields by which to sort results in ascending order.\n * @requiredField fields\n * @returns Refined WixDataSearch object.\n */\n ascending(...fields: string[]): WixDataSearch\n /**\n * @param fields - Array of fields by which to sort results in ascending order.\n * @returns Refined WixDataSearch object.\n */\n ascending(fields: string[]): WixDataSearch\n /**\n * @param fields - Fields by which to sort results in ascending order.\n * @returns Refined WixDataSearch object.\n */\n ascending(...fields: any): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value equals the specified value.\n *\n * The `eq()` method refines the search to only match items where the value of the specified field equals the specified `value`. It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.\n *\n * Matching strings with `eq()` is case-sensitive, so `\"text\"` is not considered equal to `\"Text\"`.\n *\n * If the field contains an array, `eq()` matches the item if at least one array element equals the specified `value`.\n *\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `value`.\n * @requiredField field\n * @param value - Value to match.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n eq(field: string, value: any): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value does not equal the specified value.\n *\n * The `ne()` method refines the search to only match items where the value of the specified field does not equal the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored as a String type is considered not equal to the same number stored as a Number type.\n *\n * Matching strings with `ne()` is case-sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the value of `field` is an array, `ne()` includes items in which none of the elements of the array match the specified `value`.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `value`.\n * @requiredField field\n * @param value - Value to not match.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n ne(field: string, value: any): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value is greater than or equal to the specified value.\n *\n * The `ge()` method refines the search to only match items where the value of the specified field is greater than or equal to the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored\n * as a String type does not match the same number stored as a Number type.\n *\n * If a field contains a number as a String, that value is compared\n * alphabetically and not numerically. Items that do not have a value for the\n * specified field are ranked lowest.\n *\n * The following types of fields can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so `\"abc\"` is greater than or equal to `\"ABC\"`, but `\"ABC\"` is not greater than or equal to `\"abc\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `value`.\n * @requiredField field\n * @param value - Value to compare against.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n ge(field: string, value: string | number | Date): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value is greater than the specified value.\n *\n * The `gt()` method refines the search to only match items where the value of the specified field is greater than the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.\n *\n * If a field contains a number as a String, that value is compared alphabetically and not numerically. Items that do not have a value for the specified field are ranked lowest.\n *\n * The following types of fields can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so `\"text\"` is greater than `\"Text\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `value`.\n * @requiredField field\n * @param value - Value to compare against.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n gt(field: string, value: string | number | Date): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value is less than or equal to the specified value.\n *\n * The `le()` method refines the search to only match items where the value of the specified field is less than or equal to the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.\n *\n * If a field contains a number as a String, that value is compared alphabetically and not numerically. Items that do not have a value for the specified field are ranked lowest.\n *\n * The following types of fields can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so `\"ABC\"` is less than or equal to `\"abc\"`, but `\"abc\"` is not less than or equal to `\"ABC\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `value`.\n * @requiredField field\n * @param value - Value to compare with.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n le(field: string, value: string | number | Date): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value is less than the specified value.\n *\n * The `lt()` method refines the search to only match items where the value of the specified field is less than the specified `value`.\n *\n * It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.\n *\n * If a field contains a number as a String, that value is compared alphabetically and not numerically. Items that do not have a value for the specified field are ranked lowest.\n *\n * The following types of fields can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so `\"Text\"` is less than `\"text\"`.\n * - Reference: Compares by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `value`.\n * @requiredField field\n * @param value - Value to compare with.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n lt(field: string, value: string | number | Date): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field has a value that isn't `null` or `undefined`.\n *\n * The `isNotEmpty()` method refines the search to only match items where the value of the specified field is not `null` or `undefined`.\n *\n * If the field contains any value at all for a given item, including an empty string or an invalid value, that item matches the search filter.\n * @public\n * @documentationMaturity preview\n * @param field - Field in which to check for a non-empty value.\n * @requiredField field\n * @returns Refined WixDataSearch object.\n */\n isNotEmpty(field: string): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field does not exist or does not have any value (is null or undefined).\n *\n * The `isEmpty()` method refines the search to only match items where the specified field does not exist or where its value is `null` or `undefined`.\n *\n * If the field contains any value at all for a given item, including an empty string or an invalid value, that item does not match the search filter.\n * @public\n * @documentationMaturity preview\n * @param field - Field in which to check for an empty or non-existent value.\n * @requiredField field\n * @returns Refined WixDataSearch object.\n */\n isEmpty(field: string): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value starts with a specified string.\n *\n * The `startsWith()` method refines the search to only match items where the value of the specified field starts with the specified `string`. Matching with `startsWith()` is case-sensitive, so searching for `\"Sun\"` does not match an item that contains the text `\"sunshine\"`.\n *\n * You can only use `startsWith()` with a field whose value is a String or Reference. When using a Reference, `startsWith()` matches by the ID of the referenced item as a String.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with the `value` parameter.\n * @requiredField field\n * @param value - String to look for at the beginning of the specified field value.\n * @requiredField value\n * @returns Refined WixDataSearch object.\n */\n startsWith(field: string, value: string): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value equals any of the specified values.\n *\n * The `hasSome()` method refines the search to only match items where the value of the specified field equals any of the specified values.\n *\n * Matching strings with `hasSome()` is case-sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the specified field contains an array, `hasSome()` matches if any of the elements in that array match any of the specified values.\n *\n * If the specified field contains multiple references, pass item IDs as the values. `hasSome()` matches if any of the multiple references match any of the specified ID values.\n *\n * You can specify multiple values to match by providing an array of String, Number, or Date types as the `values` parameters.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `values`.\n * @requiredField field\n * @param values - Values to match.\n * @requiredField values\n * @returns Refined WixDataSearch object.\n */\n hasSome(field: string, ...values: string[] | number[] | Date[]): WixDataSearch\n\n /**\n * Overload for `hasSome()`. Refines a search to match items whose specified field value equals any of the specified values.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with the provided values.\n * @requiredField field\n * @param values - An array of values to match.\n * @requiredField values\n * @returns Refined WixDataSearch object.\n */\n hasSome(field: string, values: string[] | number[] | Date[]): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value equals all of the specified values.\n *\n * The `hasAll()` method refines the search to only match items where the value of the specified field equals all of the specified values.\n *\n * Matching strings with `hasAll()` is case-sensitive, so `\"text\"` is not equal to `\"Text\"`.\n *\n * If the value of the specified field is an array, `hasAll()` matches if there is a match in the elements of that array for all of the specified values.\n *\n * You can specify a list of values to match by providing an array of String, Number, or Date types as the `values` parameters.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `values`.\n * @requiredField field\n * @param values - Values to match. All specified values must be present.\n * @requiredField values\n * @returns Refined WixDataSearch object.\n */\n hasAll(field: string, ...values: string[] | number[] | Date[]): WixDataSearch\n\n /**\n * Overload for `hasAll()`. Refines a search to match items whose specified field values equals all of the specified values.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with the provided values.\n * @requiredField field\n * @param values - Array of values to match. All elements in the array must be present.\n * @requiredField values\n * @returns Refined WixDataSearch object.\n */\n hasAll(field: string, values: string[] | number[] | Date[]): WixDataSearch\n\n /**\n * Adds an `or` condition to the search filter.\n *\n * The `or()` method adds an inclusive `or` condition to the search filter. The search returns all the items that match the filter as defined up to the `or()` method, the items that match the filter passed to the `or()` method, and the items that match both.\n *\n * > **Note**: The `or()` method requires 2 or more filters. Used on its own, it might produce unexpected results.\n * @public\n * @documentationMaturity preview\n * @param filter - Filter to add to the initial filter as an `or` condition.\n * @requiredField filter\n * @returns Refined WixDataSearch object.\n */\n or(filter: WixDataFilter): WixDataSearch\n\n /**\n * Adds an `and` condition to the search filter.\n *\n * The `and()` method adds an `and` condition to the search filter. A search with an `and` returns all the items that match both the filter as defined up to the `and()` method, and the filter passed to the `and()` method.\n *\n * When chaining multiple filter methods to a search, an `and` condition is often assumed by default. For example, the search returns results whose status is active **and** age is greater than 25:\n *\n * ```javascript\n * items\n * .search(\"myCollection\")\n * .expression(\"some text\")\n * .eq(\"status\", \"active\")\n * .gt(\"age\", 25);\n * ```\n *\n * The `and()` method is needed when using compound filters. For example, the final search in this set of operations returns results whose status is either pending or rejected **and** age is either less than 25 or greater than 65:\n *\n * ```javascript\n * let statusFilter = items\n * .filter()\n * .eq(\"status\", \"pending\")\n * .or(items.filter().eq(\"status\", \"rejected\"));\n *\n * let ageFilter = items\n * .filter()\n * .lt(\"age\", 25)\n * .or(items.filter().gt(\"age\", 65));\n *\n * let finalSearch = items\n * .search(\"myCollection\")\n * .expression(\"some text\")\n * .and(statusFilter)\n * .and(ageFilter);\n * ```\n *\n * > **Note**: The `and()` method requires 2 or more filters.\n *\n * @public\n * @documentationMaturity preview\n * @param filter - Filter to add to the initial search filter as an `and` condition.\n * @requiredField filter\n * @returns Refined WixDataSearch object.\n */\n and(filter: WixDataFilter): WixDataSearch\n\n /**\n * Adds a `not` condition to the search filter.\n *\n * The `not()` method adds a `not` condition to the search filter. A search with a `not` returns all the items that match the filter as defined up to the `not()` method and don't match the filter passed to the `not()` method.\n *\n * If the search filter only contains a `not()` method, it returns all the items that don't match the filter specified to the method.\n *\n * @public\n * @documentationMaturity preview\n * @param filter - Filter to add to the initial filter as a `not` condition.\n * @requiredField filter\n * @returns Refined WixDataSearch object.\n */\n not(filter: WixDataFilter): WixDataSearch\n\n /**\n * Refines a search to match items whose specified field value is within a specified range.\n *\n * The `between()` method refines the search to only match items where the value of the specified field is greater than or equal to `rangeStart` and less than `rangeEnd`.\n *\n * It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.\n *\n * If a field contains a number as a String, that value is compared alphabetically and not numerically. Items that do not have a value for the specified field are ranked lowest.\n *\n * The following types of fields can be compared:\n * - Number: Compares numerically.\n * - Date: Compares JavaScript Date objects.\n * - String: Compares lexicographically, so\n * - `\"A\"` and `\"M\"` are between `\"A\"` and `\"Z\"`, but `\"a\"`, `\"m\"`, `\"z\"` and `\"Z\"` are not.\n * - `\"A\"`, `\"M\"`, `\"Z\"`, and `\"a\"` are between `\"A\"` and `\"z\"`, but `\"z\"` is not.\n * @public\n * @documentationMaturity preview\n * @param field - Field whose value is compared with `rangeStart` and `rangeEnd`.\n * @requiredField field\n * @param rangeStart - Starting value of the range to match (inclusive).\n * @requiredField rangeStart\n * @param rangeEnd - Ending value of the range to match (exclusive).\n * @requiredField rangeEnd\n * @returns Refined WixDataSearch object.\n */\n between(\n field: string,\n rangeStart: string | number | Date,\n rangeEnd: string | number | Date\n ): WixDataSearch\n\n /**\n * Lists the fields to return in the search results.\n *\n * The `fields()` method specifies which fields to return in the search results.\n *\n * You can use `include()` together with `fields()` to get referenced items.\n *\n * When `fields()` receives an empty or an invalid field, the search behaves as follows:\n * - When no fields are specified, the search returns all fields.\n * - When multiple fields are specified but some are invalid, invalid fields are ignored and valid fields are returned.\n * - When only invalid fields are specified, only the default `_id` field is returned.\n * @public\n * @documentationMaturity preview\n * @param fields - Fields to return.\n * @requiredField fields\n * @returns Refined WixDataSearch object.\n */\n fields(...fields: string[]): WixDataSearch\n\n /**\n * Limits the number of items the search returns.\n *\n * The `limit()` method defines the number of results a search operation returns in each page. Only one page of results is retrieved at a time. The `next()` and `prev()` methods of the [`WixDataResult`](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-result/introduction) object are used to navigate the pages of a search result.\n *\n * By default, `limit` is set to `100`.\n *\n * The maximum value that `limit()` can accept is `1000`.\n *\n * @public\n * @documentationMaturity preview\n * @param limitNumber - Number of items to return, which is also the `pageSize` of the results object.\n * @requiredField limitNumber\n * @returns Refined WixDataSearch object.\n */\n limit(limitNumber: number): WixDataSearch\n\n /**\n * Sets the number of items to skip before returning search results.\n *\n * The `skip()` method defines the number of results to skip in the search results before returning new search results.\n *\n * For example, if your search matches 50 items, but you set `skip` to 10, the results returned skips the first 10 items that match and return the 11th through 50th items.\n *\n * By default, `skip()` is set to 0.\n * @public\n * @documentationMaturity preview\n * @param skipCount - Number of items to skip before returning the results.\n * @requiredField skipCount\n * @returns Refined WixDataSearch object.\n */\n skip(skipCount: number): WixDataSearch\n\n /**\n * Includes referenced items for the specified fields.\n *\n * The `include()` method refines a search so that the items returned in the search results include the full referenced items for the specified fields.\n *\n * For example, suppose you have a **books** collection with an **author** field that references an **authors** collection. Searching the **books** collection with an `include(\"author\")` returns the relevant book items, and each item includes the full referenced author item in the book's `author` field.\n *\n * When searching a collection that contains a reference field without using the `include()` method:\n * - Single reference field: returned items contain only the ID of the referenced item, and not the full referenced items.\n * - Multiple reference field: returned items do not contain the multiple reference field at all.\n *\n * When including a field with multiple references, the following limitations apply:\n * - Only one field with multiple references can be included.\n * - The search returns an error if more than 50 items are returned, regardless of any search limit set using the `limit()` method.\n * - Each returned item can include up to 50 referenced items. If there are more than 50 referenced items, only 50 are returned, and the `partialIncludes` field of the returned `WixDataResult` is `true`.\n *\n * > **Note:** The `include()` method is not supported for [single-item collections](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection).\n *\n * @public\n * @documentationMaturity preview\n * @param fields - Fields for which to include referenced items.\n * @requiredField fields\n * @returns Refined WixDataSearch object.\n */\n include(...fields: string[]): WixDataSearch\n\n /**\n * Overload for `include()`. Includes referenced items for the specified field in a search's results.\n * @public\n * @documentationMaturity preview\n * @param field - Field for which to include referenced items.\n * @param limit - Optional limit for the number of referenced items to include (behavior may vary).\n * @returns Refined WixDataSearch object.\n */\n include(field: string, limit?: number): WixDataSearch\n\n /**\n * Overload for `include()`. Includes referenced items for the specified fields in a search's results.\n * @public\n * @documentationMaturity preview\n * @param field1 - First field for which to include referenced items.\n * @param field2 - Second field for which to include referenced items.\n * @param limit - Optional limit for the number of referenced items to include (behavior may vary).\n * @returns Refined WixDataSearch object.\n */\n include(field1: string, field2: string, limit?: number): WixDataSearch\n\n /**\n * Overload for `include()`. Includes referenced items for the specified fields in a search's results.\n * @public\n * @documentationMaturity preview\n * @param field1 - First field.\n * @param field2 - Second field.\n * @param field3 - Third field.\n * @param limit - Optional limit.\n * @returns Refined WixDataSearch object.\n */\n include(\n field1: string,\n field2: string,\n field3: string,\n limit?: number\n ): WixDataSearch\n\n /**\n * Overload for `include()`. Includes referenced items for the specified fields in a search's results.\n * @public\n * @documentationMaturity preview\n * @param field1 - First field.\n * @param field2 - Second field.\n * @param field3 - Third field.\n * @param field4 - Fourth field.\n * @param limit - Optional limit.\n * @returns Refined WixDataSearch object.\n */\n include(\n field1: string,\n field2: string,\n field3: string,\n field4: string,\n limit?: number\n ): WixDataSearch\n\n /**\n * Overload for `include()`. Includes referenced items for the specified fields in a search's results.\n * @public\n * @documentationMaturity preview\n * @param field1 - First field.\n * @param field2 - Second field.\n * @param field3 - Third field.\n * @param field4 - Fourth field.\n * @param field5 - Fifth field.\n * @param limit - Optional limit.\n * @returns Refined WixDataSearch object.\n */\n include(\n field1: string,\n field2: string,\n field3: string,\n field4: string,\n field5: string,\n limit?: number\n ): WixDataSearch\n\n /**\n * Overload for `include()`. Includes referenced items for the specified fields in a search's results.\n * Allows specifying multiple field names and an optional limit.\n * @public\n * @documentationMaturity preview\n * @param fieldNamesAndLimit - Array of field names, optionally followed by a limit number.\n * @returns Refined WixDataSearch object.\n */\n include(...fieldNamesAndLimit: [...string[], number]): WixDataSearch\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -8,32 +8,32 @@ import { WixDataFilter } from './WixDataFilter';
|
|
|
8
8
|
*/
|
|
9
9
|
export interface WixDataSearch {
|
|
10
10
|
/**
|
|
11
|
-
* Specifies the text to search
|
|
11
|
+
* Specifies the text to search in the collection.
|
|
12
12
|
*
|
|
13
13
|
* The `expression()` method sets the search query. Search terms are separated by whitespace.
|
|
14
14
|
*
|
|
15
|
-
* @param queryText - Text to search
|
|
15
|
+
* @param queryText - Text to search in the collection.
|
|
16
16
|
* @returns Refined WixDataSearch object.
|
|
17
17
|
*/
|
|
18
18
|
expression(queryText: string): WixDataSearch;
|
|
19
19
|
/**
|
|
20
20
|
* Enables fuzzy search for approximate text matching.
|
|
21
21
|
*
|
|
22
|
-
* The `fuzzy()` method enables fuzzy search. This allows for approximate matches that closely resemble the search expression even if they don't match
|
|
22
|
+
* The `fuzzy()` method enables fuzzy search. This allows for approximate matches that closely resemble the search expression even if they don't exactly match.
|
|
23
23
|
*
|
|
24
24
|
* @returns Refined WixDataSearch object.
|
|
25
25
|
*/
|
|
26
26
|
fuzzy(): WixDataSearch;
|
|
27
27
|
/**
|
|
28
|
-
* Sets the search mode to **AND
|
|
28
|
+
* Sets the search mode to **AND**.
|
|
29
29
|
*
|
|
30
|
-
* When in **AND** mode, an item must include all specified search terms
|
|
30
|
+
* When in **AND** mode, an item must include all specified search terms to be included in the results. For example, the search expression "red car" in **AND** mode only retrieves items that include both "red" and "car".
|
|
31
31
|
*
|
|
32
32
|
* @returns Refined WixDataSearch object.
|
|
33
33
|
*/
|
|
34
34
|
andMode(): WixDataSearch;
|
|
35
35
|
/**
|
|
36
|
-
* Sets the search mode to **OR
|
|
36
|
+
* Sets the search mode to **OR**.
|
|
37
37
|
*
|
|
38
38
|
* When in **OR** mode, an item must include at least one of the specified search terms to be included in the results. For example, the search expression "red car" in **OR** mode retrieves items that include "red", "car", or both.
|
|
39
39
|
*
|
|
@@ -43,18 +43,17 @@ export interface WixDataSearch {
|
|
|
43
43
|
/**
|
|
44
44
|
* Runs the search operation.
|
|
45
45
|
*
|
|
46
|
-
* The `run()` method searches the collection for the specified expression. It returns a Promise that resolves to a `WixDataResult` that contains the matching items and search metadata.
|
|
46
|
+
* The `run()` method searches the collection for the specified expression. It returns a Promise that resolves to a [`WixDataResult`](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-result/introduction) that contains the matching items and search metadata.
|
|
47
47
|
*
|
|
48
|
-
* Search operations are [eventually consistent](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency) and
|
|
49
|
-
* @param options -
|
|
50
|
-
* @returns Promise that resolves to a WixDataResult containing the matching items and search metadata.
|
|
48
|
+
* Search operations are [eventually consistent](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency) and might not reflect recent changes.
|
|
49
|
+
* @param options - Options for building the search operation.
|
|
50
|
+
* @returns Promise that resolves to a [`WixDataResult`](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-result/introduction) containing the matching items and search metadata.
|
|
51
51
|
*/
|
|
52
52
|
run(options?: WixDataReadOptions): Promise<WixDataResult>;
|
|
53
53
|
/**
|
|
54
54
|
* Sorts search results by the specified fields in descending order.
|
|
55
55
|
*
|
|
56
|
-
* The `descending()` method refines the search to sort results in descending order
|
|
57
|
-
* If you specify more than one field, `descending()` sorts the results in descending order by each field in the order they are listed.
|
|
56
|
+
* The `descending()` method refines the search to sort results by the specified fields in descending order. If you specify more than one field, `descending()` sorts the results in descending order by each field in the order they are listed.
|
|
58
57
|
*
|
|
59
58
|
* You can sort the following types:
|
|
60
59
|
* - **Number**: Sorts numerically.
|
|
@@ -73,20 +72,19 @@ export interface WixDataSearch {
|
|
|
73
72
|
*/
|
|
74
73
|
descending(...fields: string[]): WixDataSearch;
|
|
75
74
|
/**
|
|
76
|
-
* @param fields - Array of fields to sort
|
|
75
|
+
* @param fields - Array of fields by which to sort results in descending order.
|
|
77
76
|
* @returns Refined WixDataSearch object.
|
|
78
77
|
*/
|
|
79
78
|
descending(fields: string[]): WixDataSearch;
|
|
80
79
|
/**
|
|
81
|
-
* @param fields - Fields
|
|
80
|
+
* @param fields - Fields by which to sort results in descending order.
|
|
82
81
|
* @returns Refined WixDataSearch object.
|
|
83
82
|
*/
|
|
84
83
|
descending(...fields: any): WixDataSearch;
|
|
85
84
|
/**
|
|
86
|
-
* Sorts search results by the specified fields
|
|
85
|
+
* Sorts search results in ascending order by the specified fields.
|
|
87
86
|
*
|
|
88
|
-
* The `ascending()` method refines the search to sort results in ascending order
|
|
89
|
-
* If you specify more than one field, `ascending()` sorts the results in ascending order by each field in the order they are listed.
|
|
87
|
+
* The `ascending()` method refines the search to sort results by the specified fields in ascending order. If you specify more than one field, `ascending()` sorts the results in ascending order by each field in the order they are listed.
|
|
90
88
|
*
|
|
91
89
|
* You can sort the following types:
|
|
92
90
|
* - **Number**: Sorts numerically.
|
|
@@ -105,12 +103,12 @@ export interface WixDataSearch {
|
|
|
105
103
|
*/
|
|
106
104
|
ascending(...fields: string[]): WixDataSearch;
|
|
107
105
|
/**
|
|
108
|
-
* @param fields - Array of fields to sort
|
|
106
|
+
* @param fields - Array of fields by which to sort results in ascending order.
|
|
109
107
|
* @returns Refined WixDataSearch object.
|
|
110
108
|
*/
|
|
111
109
|
ascending(fields: string[]): WixDataSearch;
|
|
112
110
|
/**
|
|
113
|
-
* @param fields - Fields
|
|
111
|
+
* @param fields - Fields by which to sort results in ascending order.
|
|
114
112
|
* @returns Refined WixDataSearch object.
|
|
115
113
|
*/
|
|
116
114
|
ascending(...fields: any): WixDataSearch;
|
|
@@ -119,7 +117,7 @@ export interface WixDataSearch {
|
|
|
119
117
|
*
|
|
120
118
|
* The `eq()` method refines the search to only match items where the value of the specified field equals the specified `value`. It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.
|
|
121
119
|
*
|
|
122
|
-
* Matching strings with `eq()` is case-sensitive, so `"text"` is not equal to `"Text"`.
|
|
120
|
+
* Matching strings with `eq()` is case-sensitive, so `"text"` is not considered equal to `"Text"`.
|
|
123
121
|
*
|
|
124
122
|
* If the field contains an array, `eq()` matches the item if at least one array element equals the specified `value`.
|
|
125
123
|
*
|
|
@@ -135,11 +133,9 @@ export interface WixDataSearch {
|
|
|
135
133
|
/**
|
|
136
134
|
* Refines a search to match items whose specified field value does not equal the specified value.
|
|
137
135
|
*
|
|
138
|
-
* The `ne()` method refines
|
|
139
|
-
* match items where the value of the specified field does not equal the specified `value`.
|
|
136
|
+
* The `ne()` method refines the search to only match items where the value of the specified field does not equal the specified `value`.
|
|
140
137
|
*
|
|
141
|
-
* It only matches values of the same type. For example, a number value stored
|
|
142
|
-
* as a String type is considered not equal to the same number stored as a Number type.
|
|
138
|
+
* It only matches values of the same type. For example, a number value stored as a String type is considered not equal to the same number stored as a Number type.
|
|
143
139
|
*
|
|
144
140
|
* Matching strings with `ne()` is case-sensitive, so `"text"` is not equal to `"Text"`.
|
|
145
141
|
*
|
|
@@ -154,12 +150,9 @@ export interface WixDataSearch {
|
|
|
154
150
|
*/
|
|
155
151
|
ne(field: string, value: any): WixDataSearch;
|
|
156
152
|
/**
|
|
157
|
-
* Refines a search to match items whose specified field value is greater than or equal to the specified
|
|
158
|
-
* value.
|
|
153
|
+
* Refines a search to match items whose specified field value is greater than or equal to the specified value.
|
|
159
154
|
*
|
|
160
|
-
* The `ge()` method refines
|
|
161
|
-
* match items where the value of the specified field is greater than or
|
|
162
|
-
* equal to the specified `value`.
|
|
155
|
+
* The `ge()` method refines the search to only match items where the value of the specified field is greater than or equal to the specified `value`.
|
|
163
156
|
*
|
|
164
157
|
* It only matches values of the same type. For example, a number value stored
|
|
165
158
|
* as a String type does not match the same number stored as a Number type.
|
|
@@ -171,9 +164,7 @@ export interface WixDataSearch {
|
|
|
171
164
|
* The following types of fields can be compared:
|
|
172
165
|
* - Number: Compares numerically.
|
|
173
166
|
* - Date: Compares JavaScript Date objects.
|
|
174
|
-
* - String: Compares lexicographically,
|
|
175
|
-
* so `"abc"` is greater than or equal to `"ABC"` (because of the greater than),
|
|
176
|
-
* but `"ABC"` is not greater than or equal to `"abc"`.
|
|
167
|
+
* - String: Compares lexicographically, so `"abc"` is greater than or equal to `"ABC"`, but `"ABC"` is not greater than or equal to `"abc"`.
|
|
177
168
|
* - Reference: Compares by the ID of the referenced item as a String.
|
|
178
169
|
* @public
|
|
179
170
|
* @documentationMaturity preview
|
|
@@ -187,7 +178,7 @@ export interface WixDataSearch {
|
|
|
187
178
|
/**
|
|
188
179
|
* Refines a search to match items whose specified field value is greater than the specified value.
|
|
189
180
|
*
|
|
190
|
-
* The `gt()` method refines
|
|
181
|
+
* The `gt()` method refines the search to only match items where the value of the specified field is greater than the specified `value`.
|
|
191
182
|
*
|
|
192
183
|
* It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.
|
|
193
184
|
*
|
|
@@ -200,7 +191,7 @@ export interface WixDataSearch {
|
|
|
200
191
|
* - Reference: Compares by the ID of the referenced item as a String.
|
|
201
192
|
* @public
|
|
202
193
|
* @documentationMaturity preview
|
|
203
|
-
* @param field -
|
|
194
|
+
* @param field - Field whose value is compared with `value`.
|
|
204
195
|
* @requiredField field
|
|
205
196
|
* @param value - Value to compare against.
|
|
206
197
|
* @requiredField value
|
|
@@ -208,32 +199,24 @@ export interface WixDataSearch {
|
|
|
208
199
|
*/
|
|
209
200
|
gt(field: string, value: string | number | Date): WixDataSearch;
|
|
210
201
|
/**
|
|
211
|
-
* Refines a search to match items whose specified field value is less than or equal to the specified
|
|
212
|
-
* value.
|
|
202
|
+
* Refines a search to match items whose specified field value is less than or equal to the specified value.
|
|
213
203
|
*
|
|
214
|
-
* The `le()` method refines
|
|
215
|
-
* items where the value of the specified field is less than or equal to the
|
|
216
|
-
* specified `value`.
|
|
204
|
+
* The `le()` method refines the search to only match items where the value of the specified field is less than or equal to the specified `value`.
|
|
217
205
|
*
|
|
218
|
-
* It only matches values of the same type. For example, a number value stored
|
|
219
|
-
* as a String type does not match the same number stored as a Number type.
|
|
206
|
+
* It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.
|
|
220
207
|
*
|
|
221
|
-
* If a field contains a number as a String, that value is compared
|
|
222
|
-
* alphabetically and not numerically. Items that do not have a value for the
|
|
223
|
-
* specified field are ranked lowest.
|
|
208
|
+
* If a field contains a number as a String, that value is compared alphabetically and not numerically. Items that do not have a value for the specified field are ranked lowest.
|
|
224
209
|
*
|
|
225
210
|
* The following types of fields can be compared:
|
|
226
211
|
* - Number: Compares numerically.
|
|
227
212
|
* - Date: Compares JavaScript Date objects.
|
|
228
|
-
* - String: Compares lexicographically,
|
|
229
|
-
* so `"ABC"` is less than or equal to `"abc"` (because of the less than),
|
|
230
|
-
* but `"abc"` is not less than or equal to `"ABC"`.
|
|
213
|
+
* - String: Compares lexicographically, so `"ABC"` is less than or equal to `"abc"`, but `"abc"` is not less than or equal to `"ABC"`.
|
|
231
214
|
* - Reference: Compares by the ID of the referenced item as a String.
|
|
232
215
|
* @public
|
|
233
216
|
* @documentationMaturity preview
|
|
234
217
|
* @param field - Field whose value is compared with `value`.
|
|
235
218
|
* @requiredField field
|
|
236
|
-
* @param value - Value to compare
|
|
219
|
+
* @param value - Value to compare with.
|
|
237
220
|
* @requiredField value
|
|
238
221
|
* @returns Refined WixDataSearch object.
|
|
239
222
|
*/
|
|
@@ -241,15 +224,11 @@ export interface WixDataSearch {
|
|
|
241
224
|
/**
|
|
242
225
|
* Refines a search to match items whose specified field value is less than the specified value.
|
|
243
226
|
*
|
|
244
|
-
* The `lt()` method refines
|
|
245
|
-
* items where the value of the specified field is less than the specified `value`.
|
|
227
|
+
* The `lt()` method refines the search to only match items where the value of the specified field is less than the specified `value`.
|
|
246
228
|
*
|
|
247
|
-
* It only matches values of the same type. For example, a number value stored
|
|
248
|
-
* as a String type does not match the same number stored as a Number type.
|
|
229
|
+
* It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.
|
|
249
230
|
*
|
|
250
|
-
* If a field contains a number as a String, that value is compared
|
|
251
|
-
* alphabetically and not numerically. Items that do not have a value for the
|
|
252
|
-
* specified field are ranked lowest.
|
|
231
|
+
* If a field contains a number as a String, that value is compared alphabetically and not numerically. Items that do not have a value for the specified field are ranked lowest.
|
|
253
232
|
*
|
|
254
233
|
* The following types of fields can be compared:
|
|
255
234
|
* - Number: Compares numerically.
|
|
@@ -260,19 +239,17 @@ export interface WixDataSearch {
|
|
|
260
239
|
* @documentationMaturity preview
|
|
261
240
|
* @param field - Field whose value is compared with `value`.
|
|
262
241
|
* @requiredField field
|
|
263
|
-
* @param value - Value to compare
|
|
242
|
+
* @param value - Value to compare with.
|
|
264
243
|
* @requiredField value
|
|
265
244
|
* @returns Refined WixDataSearch object.
|
|
266
245
|
*/
|
|
267
246
|
lt(field: string, value: string | number | Date): WixDataSearch;
|
|
268
247
|
/**
|
|
269
|
-
* Refines a search to match items whose specified field has
|
|
248
|
+
* Refines a search to match items whose specified field has a value that isn't `null` or `undefined`.
|
|
270
249
|
*
|
|
271
|
-
* The `isNotEmpty()` method refines
|
|
272
|
-
* value of the specified field is not `null` or `undefined`.
|
|
250
|
+
* The `isNotEmpty()` method refines the search to only match items where the value of the specified field is not `null` or `undefined`.
|
|
273
251
|
*
|
|
274
|
-
* If the field contains any value at all for a given item, including the
|
|
275
|
-
* empty string or an invalid value, that item will match the search filter.
|
|
252
|
+
* If the field contains any value at all for a given item, including an empty string or an invalid value, that item matches the search filter.
|
|
276
253
|
* @public
|
|
277
254
|
* @documentationMaturity preview
|
|
278
255
|
* @param field - Field in which to check for a non-empty value.
|
|
@@ -283,12 +260,9 @@ export interface WixDataSearch {
|
|
|
283
260
|
/**
|
|
284
261
|
* Refines a search to match items whose specified field does not exist or does not have any value (is null or undefined).
|
|
285
262
|
*
|
|
286
|
-
* The `isEmpty()` method refines
|
|
287
|
-
* value of the specified field is `null` or `undefined` or the field does
|
|
288
|
-
* not exist.
|
|
263
|
+
* The `isEmpty()` method refines the search to only match items where the specified field does not exist or where its value is `null` or `undefined`.
|
|
289
264
|
*
|
|
290
|
-
* If the field contains any value at all for a given item, including the
|
|
291
|
-
* empty string or an invalid value, that item will not match the search filter.
|
|
265
|
+
* If the field contains any value at all for a given item, including an empty string or an invalid value, that item does not match the search filter.
|
|
292
266
|
* @public
|
|
293
267
|
* @documentationMaturity preview
|
|
294
268
|
* @param field - Field in which to check for an empty or non-existent value.
|
|
@@ -299,10 +273,9 @@ export interface WixDataSearch {
|
|
|
299
273
|
/**
|
|
300
274
|
* Refines a search to match items whose specified field value starts with a specified string.
|
|
301
275
|
*
|
|
302
|
-
* The `startsWith()` method refines
|
|
276
|
+
* The `startsWith()` method refines the search to only match items where the value of the specified field starts with the specified `string`. Matching with `startsWith()` is case-sensitive, so searching for `"Sun"` does not match an item that contains the text `"sunshine"`.
|
|
303
277
|
*
|
|
304
|
-
* You can only use `startsWith()` with a field whose value is a String or Reference.
|
|
305
|
-
* When using a Reference, `startsWith()` matches by the ID of the referenced item as Strings.
|
|
278
|
+
* You can only use `startsWith()` with a field whose value is a String or Reference. When using a Reference, `startsWith()` matches by the ID of the referenced item as a String.
|
|
306
279
|
* @public
|
|
307
280
|
* @documentationMaturity preview
|
|
308
281
|
* @param field - Field whose value is compared with the `value` parameter.
|
|
@@ -347,18 +320,13 @@ export interface WixDataSearch {
|
|
|
347
320
|
/**
|
|
348
321
|
* Refines a search to match items whose specified field value equals all of the specified values.
|
|
349
322
|
*
|
|
350
|
-
* The `hasAll()` method refines
|
|
351
|
-
* only match items where the value of the specified field equals all of
|
|
352
|
-
* the specified values.
|
|
323
|
+
* The `hasAll()` method refines the search to only match items where the value of the specified field equals all of the specified values.
|
|
353
324
|
*
|
|
354
325
|
* Matching strings with `hasAll()` is case-sensitive, so `"text"` is not equal to `"Text"`.
|
|
355
326
|
*
|
|
356
|
-
* If the value of the specified field is an array, `hasAll()`
|
|
357
|
-
* if there is a match in the elements of that array for all of the specified
|
|
358
|
-
* values.
|
|
327
|
+
* If the value of the specified field is an array, `hasAll()` matches if there is a match in the elements of that array for all of the specified values.
|
|
359
328
|
*
|
|
360
|
-
* You can specify a list of values to match by providing an array of
|
|
361
|
-
* String, Number, or Date types as the `values` parameters.
|
|
329
|
+
* You can specify a list of values to match by providing an array of String, Number, or Date types as the `values` parameters.
|
|
362
330
|
* @public
|
|
363
331
|
* @documentationMaturity preview
|
|
364
332
|
* @param field - Field whose value is compared with `values`.
|
|
@@ -374,7 +342,7 @@ export interface WixDataSearch {
|
|
|
374
342
|
* @documentationMaturity preview
|
|
375
343
|
* @param field - Field whose value is compared with the provided values.
|
|
376
344
|
* @requiredField field
|
|
377
|
-
* @param values - Array of values to match. All
|
|
345
|
+
* @param values - Array of values to match. All elements in the array must be present.
|
|
378
346
|
* @requiredField values
|
|
379
347
|
* @returns Refined WixDataSearch object.
|
|
380
348
|
*/
|
|
@@ -382,9 +350,9 @@ export interface WixDataSearch {
|
|
|
382
350
|
/**
|
|
383
351
|
* Adds an `or` condition to the search filter.
|
|
384
352
|
*
|
|
385
|
-
* The `or()` method adds an inclusive `or` condition to
|
|
353
|
+
* The `or()` method adds an inclusive `or` condition to the search filter. The search returns all the items that match the filter as defined up to the `or()` method, the items that match the filter passed to the `or()` method, and the items that match both.
|
|
386
354
|
*
|
|
387
|
-
* > **Note**: The `or()` method
|
|
355
|
+
* > **Note**: The `or()` method requires 2 or more filters. Used on its own, it might produce unexpected results.
|
|
388
356
|
* @public
|
|
389
357
|
* @documentationMaturity preview
|
|
390
358
|
* @param filter - Filter to add to the initial filter as an `or` condition.
|
|
@@ -395,25 +363,39 @@ export interface WixDataSearch {
|
|
|
395
363
|
/**
|
|
396
364
|
* Adds an `and` condition to the search filter.
|
|
397
365
|
*
|
|
398
|
-
* The `and()` method adds an `and` condition to the search filter. A search with an `and` returns all the items that match the filter as defined up to the `and()` method,
|
|
366
|
+
* The `and()` method adds an `and` condition to the search filter. A search with an `and` returns all the items that match both the filter as defined up to the `and()` method, and the filter passed to the `and()` method.
|
|
399
367
|
*
|
|
400
|
-
* When chaining multiple filter methods to a search, an `and` condition is often assumed by default. For example,
|
|
368
|
+
* When chaining multiple filter methods to a search, an `and` condition is often assumed by default. For example, the search returns results whose status is active **and** age is greater than 25:
|
|
401
369
|
*
|
|
402
370
|
* ```javascript
|
|
403
|
-
* items
|
|
371
|
+
* items
|
|
372
|
+
* .search("myCollection")
|
|
373
|
+
* .expression("some text")
|
|
374
|
+
* .eq("status", "active")
|
|
375
|
+
* .gt("age", 25);
|
|
404
376
|
* ```
|
|
405
377
|
*
|
|
406
|
-
* The `and()` method is needed when
|
|
378
|
+
* The `and()` method is needed when using compound filters. For example, the final search in this set of operations returns results whose status is either pending or rejected **and** age is either less than 25 or greater than 65:
|
|
407
379
|
*
|
|
408
380
|
* ```javascript
|
|
409
|
-
* let statusFilter = items
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
381
|
+
* let statusFilter = items
|
|
382
|
+
* .filter()
|
|
383
|
+
* .eq("status", "pending")
|
|
384
|
+
* .or(items.filter().eq("status", "rejected"));
|
|
385
|
+
*
|
|
386
|
+
* let ageFilter = items
|
|
387
|
+
* .filter()
|
|
388
|
+
* .lt("age", 25)
|
|
389
|
+
* .or(items.filter().gt("age", 65));
|
|
390
|
+
*
|
|
391
|
+
* let finalSearch = items
|
|
392
|
+
* .search("myCollection")
|
|
393
|
+
* .expression("some text")
|
|
394
|
+
* .and(statusFilter)
|
|
395
|
+
* .and(ageFilter);
|
|
414
396
|
* ```
|
|
415
397
|
*
|
|
416
|
-
* > **Note**: The `and()` method
|
|
398
|
+
* > **Note**: The `and()` method requires 2 or more filters.
|
|
417
399
|
*
|
|
418
400
|
* @public
|
|
419
401
|
* @documentationMaturity preview
|
|
@@ -439,14 +421,11 @@ export interface WixDataSearch {
|
|
|
439
421
|
/**
|
|
440
422
|
* Refines a search to match items whose specified field value is within a specified range.
|
|
441
423
|
*
|
|
442
|
-
* The `between()` method refines
|
|
443
|
-
* greater than or equal to `rangeStart` and less than `rangeEnd`.
|
|
424
|
+
* The `between()` method refines the search to only match items where the value of the specified field is greater than or equal to `rangeStart` and less than `rangeEnd`.
|
|
444
425
|
*
|
|
445
|
-
* It only matches values of the same type. For example, a number value stored as a String type does not match the
|
|
446
|
-
* same number stored as a Number type.
|
|
426
|
+
* It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.
|
|
447
427
|
*
|
|
448
|
-
* If a field contains a number as a String, that value is compared alphabetically and not numerically. Items
|
|
449
|
-
* that do not have a value for the specified field are ranked lowest.
|
|
428
|
+
* If a field contains a number as a String, that value is compared alphabetically and not numerically. Items that do not have a value for the specified field are ranked lowest.
|
|
450
429
|
*
|
|
451
430
|
* The following types of fields can be compared:
|
|
452
431
|
* - Number: Compares numerically.
|
|
@@ -456,7 +435,7 @@ export interface WixDataSearch {
|
|
|
456
435
|
* - `"A"`, `"M"`, `"Z"`, and `"a"` are between `"A"` and `"z"`, but `"z"` is not.
|
|
457
436
|
* @public
|
|
458
437
|
* @documentationMaturity preview
|
|
459
|
-
* @param field - Field whose value is compared with rangeStart and rangeEnd
|
|
438
|
+
* @param field - Field whose value is compared with `rangeStart` and `rangeEnd`.
|
|
460
439
|
* @requiredField field
|
|
461
440
|
* @param rangeStart - Starting value of the range to match (inclusive).
|
|
462
441
|
* @requiredField rangeStart
|
|
@@ -466,13 +445,13 @@ export interface WixDataSearch {
|
|
|
466
445
|
*/
|
|
467
446
|
between(field: string, rangeStart: string | number | Date, rangeEnd: string | number | Date): WixDataSearch;
|
|
468
447
|
/**
|
|
469
|
-
* Lists the fields to return in
|
|
448
|
+
* Lists the fields to return in the search results.
|
|
470
449
|
*
|
|
471
450
|
* The `fields()` method specifies which fields to return in the search results.
|
|
472
451
|
*
|
|
473
|
-
* You can use `include()`
|
|
452
|
+
* You can use `include()` together with `fields()` to get referenced items.
|
|
474
453
|
*
|
|
475
|
-
* When `fields()` receives an empty or invalid field, the search behaves as follows:
|
|
454
|
+
* When `fields()` receives an empty or an invalid field, the search behaves as follows:
|
|
476
455
|
* - When no fields are specified, the search returns all fields.
|
|
477
456
|
* - When multiple fields are specified but some are invalid, invalid fields are ignored and valid fields are returned.
|
|
478
457
|
* - When only invalid fields are specified, only the default `_id` field is returned.
|
|
@@ -486,10 +465,7 @@ export interface WixDataSearch {
|
|
|
486
465
|
/**
|
|
487
466
|
* Limits the number of items the search returns.
|
|
488
467
|
*
|
|
489
|
-
* The `limit()` method defines the number of results a search returns in each
|
|
490
|
-
* page. Only one page of results is retrieved at a time. The `next()`
|
|
491
|
-
* and `prev()` methods of the `WixDataResult` object are used to
|
|
492
|
-
* navigate the pages of a search result.
|
|
468
|
+
* The `limit()` method defines the number of results a search operation returns in each page. Only one page of results is retrieved at a time. The `next()` and `prev()` methods of the [`WixDataResult`](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-result/introduction) object are used to navigate the pages of a search result.
|
|
493
469
|
*
|
|
494
470
|
* By default, `limit` is set to `100`.
|
|
495
471
|
*
|
|
@@ -505,44 +481,33 @@ export interface WixDataSearch {
|
|
|
505
481
|
/**
|
|
506
482
|
* Sets the number of items to skip before returning search results.
|
|
507
483
|
*
|
|
508
|
-
* The `skip()` method defines the number of results to skip in the search
|
|
509
|
-
* results before returning new search results.
|
|
484
|
+
* The `skip()` method defines the number of results to skip in the search results before returning new search results.
|
|
510
485
|
*
|
|
511
|
-
* For example, if your search matches 50 items, but
|
|
512
|
-
* you set `skip` to 10, the results returned will skip the first 10 items
|
|
513
|
-
* that match and return the 11th through 50th items.
|
|
486
|
+
* For example, if your search matches 50 items, but you set `skip` to 10, the results returned skips the first 10 items that match and return the 11th through 50th items.
|
|
514
487
|
*
|
|
515
|
-
* By default, `skip` is set to 0.
|
|
488
|
+
* By default, `skip()` is set to 0.
|
|
516
489
|
* @public
|
|
517
490
|
* @documentationMaturity preview
|
|
518
|
-
* @param skipCount - Number of items to skip
|
|
491
|
+
* @param skipCount - Number of items to skip before returning the results.
|
|
519
492
|
* @requiredField skipCount
|
|
520
493
|
* @returns Refined WixDataSearch object.
|
|
521
494
|
*/
|
|
522
495
|
skip(skipCount: number): WixDataSearch;
|
|
523
496
|
/**
|
|
524
|
-
* Includes referenced items for the specified fields
|
|
497
|
+
* Includes referenced items for the specified fields.
|
|
525
498
|
*
|
|
526
|
-
* The `include()` method refines a search so that the items returned in the
|
|
527
|
-
* search's results include the full referenced items for the specified fields.
|
|
499
|
+
* The `include()` method refines a search so that the items returned in the search results include the full referenced items for the specified fields.
|
|
528
500
|
*
|
|
529
|
-
* For example, suppose you have a **books** collection with an **author** field that references an **authors** collection. Searching the **books** collection with an `include("author")` returns the relevant book items and each item
|
|
501
|
+
* For example, suppose you have a **books** collection with an **author** field that references an **authors** collection. Searching the **books** collection with an `include("author")` returns the relevant book items, and each item includes the full referenced author item in the book's `author` field.
|
|
530
502
|
*
|
|
531
|
-
* When searching a collection that contains a reference field without using the
|
|
532
|
-
*
|
|
533
|
-
* -
|
|
534
|
-
* referenced item, and not the full referenced items.
|
|
535
|
-
* - Multiple reference field: returned items do not contain the multiple
|
|
536
|
-
* reference field at all.
|
|
503
|
+
* When searching a collection that contains a reference field without using the `include()` method:
|
|
504
|
+
* - Single reference field: returned items contain only the ID of the referenced item, and not the full referenced items.
|
|
505
|
+
* - Multiple reference field: returned items do not contain the multiple reference field at all.
|
|
537
506
|
*
|
|
538
|
-
*
|
|
539
|
-
* apply:
|
|
507
|
+
* When including a field with multiple references, the following limitations apply:
|
|
540
508
|
* - Only one field with multiple references can be included.
|
|
541
|
-
* - The search
|
|
542
|
-
*
|
|
543
|
-
* - Each returned item can include up to 50 referenced items. If there are more
|
|
544
|
-
* than 50 referenced items, only 50 are returned when the search is run
|
|
545
|
-
* and the `partialIncludes` field of the returned `WixDataResult` is `true`.
|
|
509
|
+
* - The search returns an error if more than 50 items are returned, regardless of any search limit set using the `limit()` method.
|
|
510
|
+
* - Each returned item can include up to 50 referenced items. If there are more than 50 referenced items, only 50 are returned, and the `partialIncludes` field of the returned `WixDataResult` is `true`.
|
|
546
511
|
*
|
|
547
512
|
* > **Note:** The `include()` method is not supported for [single-item collections](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection).
|
|
548
513
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WixDataSearch.d.ts","sourceRoot":"","sources":["../../../src/api/WixDataSearch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;OAOG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CAAA;IAE5C;;;;;;OAMG;IACH,KAAK,IAAI,aAAa,CAAA;IAEtB;;;;;;OAMG;IACH,OAAO,IAAI,aAAa,CAAA;IAExB;;;;;;OAMG;IACH,MAAM,IAAI,aAAa,CAAA;IAEvB;;;;;;;;OAQG;IACH,GAAG,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;IAEzD
|
|
1
|
+
{"version":3,"file":"WixDataSearch.d.ts","sourceRoot":"","sources":["../../../src/api/WixDataSearch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;OAOG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CAAA;IAE5C;;;;;;OAMG;IACH,KAAK,IAAI,aAAa,CAAA;IAEtB;;;;;;OAMG;IACH,OAAO,IAAI,aAAa,CAAA;IAExB;;;;;;OAMG;IACH,MAAM,IAAI,aAAa,CAAA;IAEvB;;;;;;;;OAQG;IACH,GAAG,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;IAEzD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAA;IAC9C;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAA;IAC3C;;;OAGG;IACH,UAAU,CAAC,GAAG,MAAM,EAAE,GAAG,GAAG,aAAa,CAAA;IAEzC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,SAAS,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAA;IAC7C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAA;IAC1C;;;OAGG;IACH,SAAS,CAAC,GAAG,MAAM,EAAE,GAAG,GAAG,aAAa,CAAA;IAExC;;;;;;;;;;;;;;;;OAgBG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,aAAa,CAAA;IAE5C;;;;;;;;;;;;;;;;;OAiBG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,aAAa,CAAA;IAE5C;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,aAAa,CAAA;IAE/D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,aAAa,CAAA;IAE/D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,aAAa,CAAA;IAE/D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,aAAa,CAAA;IAE/D;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAA;IAExC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAA;IAErC;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAAA;IAEvD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,aAAa,CAAA;IAE9E;;;;;;;;;OASG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,aAAa,CAAA;IAE3E;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,aAAa,CAAA;IAE7E;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,aAAa,CAAA;IAE1E;;;;;;;;;;;OAWG;IACH,EAAE,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAAA;IAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACH,GAAG,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAAA;IAEzC;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAAA;IAEzC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,OAAO,CACL,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAClC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAC/B,aAAa,CAAA;IAEhB;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAA;IAE1C;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,CAAA;IAEzC;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CAAA;IAEtC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,OAAO,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAA;IAE3C;;;;;;;OAOG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,CAAA;IAErD;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,CAAA;IAEtE;;;;;;;;;OASG;IACH,OAAO,CACL,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,aAAa,CAAA;IAEhB;;;;;;;;;;OAUG;IACH,OAAO,CACL,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,aAAa,CAAA;IAEhB;;;;;;;;;;;OAWG;IACH,OAAO,CACL,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,aAAa,CAAA;IAEhB;;;;;;;OAOG;IACH,OAAO,CAAC,GAAG,kBAAkB,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,MAAM,CAAC,GAAG,aAAa,CAAA;CACrE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/wix-data-items-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.164",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Rimvydas Gimbutas",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@babel/runtime": "^7.27.0",
|
|
33
33
|
"@types/kind-of": "^6.0.3",
|
|
34
34
|
"@types/safe-json-stringify": "^1.1.5",
|
|
35
|
-
"@wix/filter-builder": "1.0.
|
|
35
|
+
"@wix/filter-builder": "1.0.159",
|
|
36
36
|
"kind-of": "^6.0.3",
|
|
37
37
|
"safe-json-stringify": "^1.2.0"
|
|
38
38
|
},
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"wallaby": {
|
|
86
86
|
"autoDetect": true
|
|
87
87
|
},
|
|
88
|
-
"falconPackageHash": "
|
|
88
|
+
"falconPackageHash": "e530cbf46a77f37e3fb8ae5d89e055f0f18aabe7add848a39af514de"
|
|
89
89
|
}
|