From b4e69bd6f8a4cecf6836b1bc12dc56b03ed8962c Mon Sep 17 00:00:00 2001 From: Sam Markowitz Date: Tue, 22 Apr 2025 07:50:16 +0300 Subject: [PATCH] DocWorks for wix-data - 10 changes detected, but 12 issue detected changes: Service DataHooks was removed Service wix-data.Hooks operation afterAggregate has changed return doc Service wix-data.Hooks operation beforeAggregate has changed param context type Service wix-data.Hooks operation beforeAggregate has changed description Service wix-data.Hooks has a new operation afterDistinct Service wix-data.Hooks has a new operation beforeDistinct Service wix-data operation get has changed description Service wix-data operation query has changed description Service wix-data operation queryReferenced has changed description Service wix-data.WixDataDistinct is new issues: Operation filter has an unknown param type WixDataFilter (distinct.js (41)) Operation ascending is defined two or more times (distinct.js (92), sortMixin.js (10)) Operation descending is defined two or more times (distinct.js (116), sortMixin.js (41)) Operation eq has an unknown param type * (filterMixin.js (33)) Operation ne has an unknown param type * (filterMixin.js (59)) Operation hasSome has an unknown param type * (filterMixin.js (342)) Operation hasAll has an unknown param type * (filterMixin.js (378)) Operation beforeAggregate is defined two or more times (hooks.js (313, 337)) Operation onFailure has an unknown param type Error (hooks.js (608)) Operation truncate has an unknown return type null (data-api.js (451)) Message WixDataBulkRemoveResult has an unknown property type Error (data-api.js (485)) Message WixDataBulkResult has an unknown property type Error (data-api.js (877)) --- wix-data/DataHooks.service.json | 3 +- wix-data/wix-data.service.json | 62 ++-- wix-data/wix-data/Hooks.service.json | 134 +++++++- .../wix-data/WixDataDistinct.service.json | 321 ++++++++++++++++++ 4 files changed, 475 insertions(+), 45 deletions(-) create mode 100644 wix-data/wix-data/WixDataDistinct.service.json diff --git a/wix-data/DataHooks.service.json b/wix-data/DataHooks.service.json index 66417a6874..696308b951 100644 --- a/wix-data/DataHooks.service.json +++ b/wix-data/DataHooks.service.json @@ -1,6 +1,7 @@ { "name": "DataHooks", "mixes": [], - "labels": [], + "labels": + [ "removed" ], "location": { "lineno": 20, "filename": "hooks-standalone.js" }, diff --git a/wix-data/wix-data.service.json b/wix-data/wix-data.service.json index d503f68c25..6f40ed8d54 100644 --- a/wix-data/wix-data.service.json +++ b/wix-data/wix-data.service.json @@ -1,6 +1,7 @@ { "name": "wix-data", "mixes": [], - "labels": [], + "labels": + [ "changed" ], "location": { "lineno": 72, "filename": "data-api.js" }, @@ -152,7 +153,7 @@ { "type": "wix-data.WixDataAggregate", "doc": "An aggregate object." }, "locations": - [ { "lineno": 1069, + [ { "lineno": 1075, "filename": "data-api.js" } ], "docs": { "summary": "Creates an aggregation.", @@ -253,7 +254,7 @@ [ "wix-data.WixDataBulkResult" ] }, "doc": "Fulfilled - The results of the bulk insert.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 883, + [ { "lineno": 889, "filename": "data-api.js" } ], "docs": { "summary": "Adds a number of items to a collection.", @@ -522,7 +523,7 @@ [ "wix-data.WixDataBulkRemoveResult" ] }, "doc": "Fulfilled - The results of the bulk remove.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 490, + [ { "lineno": 495, "filename": "data-api.js" } ], "docs": { "summary": "Removes a number of items from a collection.", @@ -636,7 +637,7 @@ [ "wix-data.WixDataBulkResult" ] }, "doc": "Fulfilled - The results of the bulk save.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 946, + [ { "lineno": 952, "filename": "data-api.js" } ], "docs": { "summary": "Inserts or updates a number of items in a collection.", @@ -904,7 +905,7 @@ [ "wix-data.WixDataBulkResult" ] }, "doc": "Fulfilled - The results of the bulk save.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 1007, + [ { "lineno": 1013, "filename": "data-api.js" } ], "docs": { "summary": "Updates a number of items in a collection.", @@ -1107,7 +1108,7 @@ { "type": "wix-data.WixDataFilter", "doc": "A filter object." }, "locations": - [ { "lineno": 378, + [ { "lineno": 383, "filename": "data-api.js" } ], "docs": { "summary": "Creates a filter to be used with datasets and aggregations.", @@ -1135,7 +1136,8 @@ "extra": { } }, { "name": "get", - "labels": [], + "labels": + [ "changed" ], "nameParams": [], "params": [ { "name": "collectionId", @@ -1177,6 +1179,8 @@ " > **Notes:**", " > - When using the `query()` or `get()` functions or another data retrieval method following a change to your database collection, the data retrieved may not contain your most recent changes. See [Wix Data and Eventual Consistency](https://dev.wix.com/docs/velo/api-reference/wix-data/introduction#api-reference_wix-data_wix-data-and-eventual-consistency) for more information. To solve this problem, you can use the [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals#setTimeout) function to delay retrieving data following any changes to your database collection.", " > - To speed up data retrieval, the results of certain data queries are cached. Learn more about [caching data query results](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/data-api/about-caching-data-query-results).", + " > - When using the `query()` or `get()` functions or another data retrieval method following a change to your database collection, the data retrieved may not contain your most recent changes. See [WiX Data and Eventual Consistency](https://dev.wix.com/docs/velo/api-reference/wix-data-v2/eventual-consistency) for more information. To solve this problem, you can use the [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals#setTimeout) function to delay retrieving data following any changes to your database collection.", + " > - To speed up data retrieval, the results of certain data requests are cached. Learn more about [caching data query results](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/data-api/about-caching-data-query-results).", " > - An `itemId` is required to retrieve an item even from a single-item collection." ], "links": [], "examples": @@ -1266,7 +1270,7 @@ [ "Object" ] }, "doc": "Fulfilled - The item that was added.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 248, + [ { "lineno": 250, "filename": "data-api.js" } ], "docs": { "summary": "Adds an item to a collection.", @@ -1554,7 +1558,7 @@ [ "void" ] }, "doc": "Fulfilled - When the references have been inserted.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 737, + [ { "lineno": 743, "filename": "data-api.js" } ], "docs": { "summary": "Inserts a reference in the specified property.", @@ -1638,7 +1642,7 @@ [ "boolean" ] }, "doc": "Fulfilled - Whether the referring item contains a reference to the referenced item or not.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 839, + [ { "lineno": 845, "filename": "data-api.js" } ], "docs": { "summary": "Checks if a reference to the referenced item exists in the specified\n property of the referring item.", @@ -1674,7 +1678,8 @@ "extra": { } }, { "name": "query", - "labels": [], + "labels": + [ "changed" ], "nameParams": [], "params": [ { "name": "collectionId", @@ -1684,7 +1689,7 @@ { "type": "wix-data.WixDataQuery", "doc": "A query object." }, "locations": - [ { "lineno": 310, + [ { "lineno": 312, "filename": "data-api.js" } ], "docs": { "summary": "Creates a query for retrieving items from a database collection.", @@ -1732,7 +1737,10 @@ "", " > **Notes:**", " > - When using the `query()` or `get()` functions or another data retrieval method following a change to your database collection, the data retrieved may not contain your most recent changes. See [Wix Data and Eventual Consistency]https://dev.wix.com/docs/velo/api-reference/wix-data/introduction#api-reference_wix-data_wix-data-and-eventual-consistency) for more information. To solve this problem, you can use the [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals#setTimeout) function to delay retrieving data following any changes to your database collection.", - "> - To speed up data retrieval, the results of certain data queries are cached. Learn more about [caching data query results](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/data-api/about-caching-data-query-results)." ], + "> - To speed up data retrieval, the results of certain data queries are cached. Learn more about [caching data query results](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/data-api/about-caching-data-query-results).", + " > **Note:**", + " When using the `query()` or `get()` functions or another data retrieval method following a change to your database collection, the data retrieved may not contain your most recent changes. See [Wix Data and Eventual Consistency](https://dev.wix.com/docs/velo/api-reference/wix-data-v2/eventual-consistency) for more information. To solve this problem, you can use the [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals#setTimeout) function to delay retrieving data following any changes to your database collection.", + " > - To speed up data retrieval, the results of certain data requests are cached. Learn more about [caching data query results](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/data-api/about-caching-data-query-results)." ], "links": [], "examples": [ { "title": "Build a query", @@ -1927,7 +1935,8 @@ "extra": { } }, { "name": "queryReferenced", - "labels": [], + "labels": + [ "changed" ], "nameParams": [], "params": [ { "name": "collectionId", @@ -1952,7 +1961,7 @@ [ "wix-data.WixDataQueryReferencedResult" ] }, "doc": "Fulfilled - The referenced items.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 687, + [ { "lineno": 692, "filename": "data-api.js" } ], "docs": { "summary": "Gets the full items referenced in the specified property.", @@ -1981,6 +1990,7 @@ " > - Calling the `queryReferenced()` function does not trigger any hooks.", " > - You can only use the `queryReferenced()` function with [multiple-item reference fields](https://support.wix.com/en/article/about-referencing-multiple-items-in-one-field), and not with single-item (regular) reference fields.", " > - The `queryReferenced()` function is not supported for Single Item Collections.", + " > - To speed up data retrieval, the results of certain data requests are cached. Learn more about [caching data query results](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/data-api/about-caching-data-query-results).", "", " For a discussion of when to use the similar [`include()`](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-query/include)", " function and when to use `queryReferenced()`, see [Querying Items that Reference Other Items](https://support.wix.com/en/article/including-referenced-data-when-filtering)." ], @@ -2078,7 +2088,7 @@ [ "Object" ] }, "doc": "Fulfilled - The removed item, or `null` if the item was not found.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 406, + [ { "lineno": 411, "filename": "data-api.js" } ], "docs": { "summary": "Removes an item from a collection.", @@ -2215,7 +2225,7 @@ [ "void" ] }, "doc": "Fulfilled - When the references have been removed.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 806, + [ { "lineno": 812, "filename": "data-api.js" } ], "docs": { "summary": "Removes a reference from the specified property.", @@ -2303,7 +2313,7 @@ [ "void" ] }, "doc": "Fulfilled - When the references have been inserted.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 772, + [ { "lineno": 778, "filename": "data-api.js" } ], "docs": { "summary": "Replaces current references with references in the specified property.", @@ -2375,7 +2385,7 @@ [ "Object" ] }, "doc": "Fulfilled - The item that was either inserted or updated, depending on whether it previously existed in the collection.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 530, + [ { "lineno": 535, "filename": "data-api.js" } ], "docs": { "summary": "Inserts or updates an item in a collection.", @@ -2611,7 +2621,7 @@ { "type": "wix-data.WixDataSort", "doc": "A sort object." }, "locations": - [ { "lineno": 392, + [ { "lineno": 397, "filename": "data-api.js" } ], "docs": { "summary": "Creates a sort to be used with the dataset `setSort()` function.", @@ -2656,7 +2666,7 @@ [ "null" ] }, "doc": "Fulfilled - When the items have been removed.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 446, + [ { "lineno": 451, "filename": "data-api.js" } ], "docs": { "summary": "Removes all items from a collection.", @@ -2737,7 +2747,7 @@ [ "Object" ] }, "doc": "Fulfilled - The object that was updated.\nRejected - The error that caused the rejection." }, "locations": - [ { "lineno": 586, + [ { "lineno": 591, "filename": "data-api.js" } ], "docs": { "summary": "Updates an item in a collection.", @@ -3042,7 +3052,7 @@ "messages": [ { "name": "WixDataBulkRemoveResult", "locations": - [ { "lineno": 480, + [ { "lineno": 485, "filename": "data-api.js" } ], "docs": { "summary": "An object returned by the `bulkRemove()` function.", @@ -3074,7 +3084,7 @@ "labels": [] }, { "name": "WixDataBulkResult", "locations": - [ { "lineno": 871, + [ { "lineno": 877, "filename": "data-api.js" } ], "docs": { "summary": "An object returned by Wix Data bulk operations.", @@ -3264,7 +3274,7 @@ "labels": [] }, { "name": "WixDataQueryReferencedOptions", "locations": - [ { "lineno": 654, + [ { "lineno": 659, "filename": "data-api.js" } ], "docs": { "summary": "An object for controlling the order of returned referenced items.", diff --git a/wix-data/wix-data/Hooks.service.json b/wix-data/wix-data/Hooks.service.json index ebff624895..50d3f14016 100644 --- a/wix-data/wix-data/Hooks.service.json +++ b/wix-data/wix-data/Hooks.service.json @@ -44,7 +44,8 @@ "properties": [], "operations": [ { "name": "afterAggregate", - "labels": [], + "labels": + [ "changed" ], "nameParams": [], "params": [ { "name": "item", @@ -59,7 +60,7 @@ "typeParams": [ "Object" ] }, "Object" ], - "doc": "The item to return to [`aggregate()`](https://dev.wix.com/docs/velo/api-reference/wix-data/update) to replace the original aggregation result item.\n Returning a rejected promise returns a rejected promise to the caller and triggers the [`onFailure()`](#onFailure) hook without blocking the aggregation operation." }, + "doc": "The item to return to [`aggregate()`](https://dev.wix.com/docs/velo/api-reference/wix-data/aggregate) to replace the original aggregation result item." }, "locations": [ { "lineno": 56, "filename": "hooks.js" } ], @@ -142,7 +143,7 @@ "number" ], "doc": "The count to return to [`count()`](wix-data.WixDataQuery.html#count) instead of the original count.\n Returning a rejected promise will not block the operation, but will return a rejected promise to the caller as well as trigger the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 79, + [ { "lineno": 78, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is triggered after a `count()` operation.", @@ -216,6 +217,52 @@ { } }, "extra": { } }, + { "name": "afterDistinct", + "labels": + [ "new" ], + "nameParams": [], + "params": + [ { "name": "item", + "type": "Object", + "doc": "The distinct query result item." }, + { "name": "context", + "type": "wix-data.Hooks.HookContext", + "doc": "Contextual information about the hook." } ], + "ret": + { "type": + [ { "name": "Promise", + "typeParams": + [ "Object" ] }, + "Object" ], + "doc": "The item to return to [`distinct()`](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-query/distinct) to replace the original distinct query result item." }, + "locations": + [ { "lineno": 109, + "filename": "hooks.js" } ], + "docs": + { "summary": "A hook triggered after a distinct query operation.", + "description": + [ "The `afterDistinct()` hook allows you to modify the results of the distinct query before they are returned to the caller. The hook runs for each item in the `items` array within the [WixDataQueryResult](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-query-result/introduction) object, after the distinct query operation finishes and before the [`distinct()`](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-query/distinct) method returns.", + "", + "Return an object or a Promise that resolves to an object. If the returned value is of the wrong type, it is ignored.", + "", + "If returning a Promise, the object is used as the result regardless of whether the Promise is fulfilled or rejected. A rejected Promise also triggers the [`onFailure()`](#onFailure) hook, if it has been registered." ], + "links": [], + "examples": + [ { "title": "An `afterDistinct()` hook", + "body": + [ "// An `afterDistinct()` hook", + "//" ], + "extra": + { } }, + { "title": "Modify the item returned by `distinct()` using an `afterDistinct()` hook", + "body": + [ "// Modify the item returned by `distinct()` using an `afterDistinct()` hook." ], + "extra": + { } } ], + "extra": + { } }, + "extra": + { } }, { "name": "afterGet", "labels": [], "nameParams": [], @@ -234,7 +281,7 @@ "Object" ], "doc": "The item to return to [`get()`](wix-data.html#get) instead of the retrieved item.\n Returning a rejected promise will not block the operation, but will return a rejected promise to the operation caller as well as trigger the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 110, + [ { "lineno": 131, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is triggered after a `get()` operation.", @@ -327,7 +374,7 @@ "Object" ], "doc": "The item to return to [`insert()`](wix-data.html#insert) instead of the inserted item.\n Returning a rejected promise will not block the operation, but will return a rejected promise to the caller as well as trigger the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 142, + [ { "lineno": 163, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is triggered after an `insert()` operation.", @@ -425,7 +472,7 @@ "Object" ], "doc": "The item to return to [`find`](wix-data.WixDataQuery.html#find) instead of the item retrieved from the database.\n Returning a rejected promise will not block the operation, but will return a rejected promise to the operation caller as well as trigger the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 179, + [ { "lineno": 200, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is triggered after a `find` operation, for each of the items in the query results.", @@ -525,7 +572,7 @@ "Object" ], "doc": "The item to return to [`remove()`](wix-data.html#remove) instead of the deleted item.\n Returning a rejected promise will not block the operation, but will return a rejected promise to the caller as well as trigger the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 219, + [ { "lineno": 240, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is triggered after a `remove()` operation.", @@ -621,7 +668,7 @@ "Object" ], "doc": "The item to return to [`update()`](https://dev.wix.com/docs/velo/api-reference/wix-data/update) instead of the updated item.\n Returning a rejected promise will not block the operation, but will return a rejected promise to the caller as well as trigger the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 254, + [ { "lineno": 275, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is triggered after an `update()` operation.", @@ -711,7 +758,7 @@ "type": "wix-data.WixDataAggregate", "doc": "The original `WixDataAggregate` object." }, { "name": "context", - "type": "wix-data.Hooks.UpdateHookContext", + "type": "wix-data.Hooks.HookContext", "doc": "Contextual information about the hook." } ], "ret": { "type": @@ -721,12 +768,14 @@ "wix-data.WixDataAggregate" ], "doc": "The aggregate object to run instead of the original object created by the `aggregate()` method.\n Returning a rejected promise blocks the operation, returns a rejected promise to the caller, and triggers the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 292, + [ { "lineno": 313, + "filename": "hooks.js" }, + { "lineno": 337, "filename": "hooks.js" } ], "docs": { "summary": "A hook triggered before an aggregation operation.", "description": - [ "The `beforeAggregate()` hook runs when the [`aggregate()`](https://dev.wix.com/docs/velo/api-reference/wix-data/aggregate) is called, and allows you to modify the [`WixDataAggregate`](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-aggregate/introduction) object before the aggregation operation runs. ", + [ "The `beforeAggregate()` hook runs when the [`aggregate()`](https://dev.wix.com/docs/velo/api-reference/wix-data/aggregate) is called, and allows you to modify the [`WixDataAggregate`](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-aggregate/introduction) object before the aggregation operation runs.", "", "", " Return a [WixDataAggregate](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-aggregate/introduction) object or a Promise that resolves to a [WixDataAggregate](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-aggregate/introduction) object. The returned object is the aggregation that runs on the collection instead of the original aggregation created by the [`aggregate()`](https://dev.wix.com/docs/velo/api-reference/wix-data/aggregate) method.", @@ -805,7 +854,7 @@ "wix-data.WixDataQuery" ], "doc": "The `query` to be used for the [`count()`](wix-data.WixDataQuery.html#count) operation instead of the original query.\n Returning a rejected promise will block the operation and will return a rejected promise to the caller as well as trigger the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 316, + [ { "lineno": 360, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is triggered before a `count()` operation.", @@ -883,6 +932,55 @@ { } }, "extra": { } }, + { "name": "beforeDistinct", + "labels": + [ "new" ], + "nameParams": [], + "params": + [ { "name": "distinctQuery", + "type": "wix-data.WixDataDistinct", + "doc": "The original `WixDataDistinct` object." }, + { "name": "context", + "type": "wix-data.Hooks.HookContext", + "doc": "Contextual information about the hook." } ], + "ret": + { "type": + [ { "name": "Promise", + "typeParams": + [ "wix-data.WixDataDistinct" ] }, + "wix-data.WixDataDistinct" ], + "doc": "The distinct query object to run instead of the original object created by the `distinct()` method.\n Returning a rejected promise blocks the operation, returns a rejected promise to the caller, and triggers the [`onFailure()`](#onFailure) hook." }, + "locations": + [ { "lineno": 395, + "filename": "hooks.js" } ], + "docs": + { "summary": "A hook triggered before a distinct query operation.", + "description": + [ "The `beforeDistinct()` hook runs when the [`distinct()`](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-query/distinct) is called. It allows you to modify the [`WixDataDistinct`](ADDLINK) object before the distinct query operation runs.", + "", + "Return a [`WixDataDistinct`](ADDLINK) object or a Promise that resolves to a [`WixDataDistinct`](ADDLINK) object. The returned object defines the distinct query operation that runs on the collection instead of the original operation created by the [`distinct()`](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-query/distinct) method.", + "", + "If the returned value is of the wrong type, the value is ignored.", + "", + "A rejected Promise blocks the call to [`distinct()`](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-query/distinct) and triggers the [`onFailure()`](#onFailure) hook, if it has been registered." ], + "links": [], + "examples": + [ { "title": "A `beforeDistinct` hook", + "body": + [ "// A `beforeDistinct` hook", + "//" ], + "extra": + { } }, + { "title": "Refine the `WixDataDistinct` object", + "body": + [ "// Refine the `WixDataDistinct` object", + "//" ], + "extra": + { } } ], + "extra": + { } }, + "extra": + { } }, { "name": "beforeGet", "labels": [], "nameParams": [], @@ -901,7 +999,7 @@ "string" ], "doc": "The ID to be used for the [`get()`](wix-data.html#get) operation instead of the original `itemId` specified by the caller.\n Returning a rejected promise will block the operation and will return a rejected promise to the caller as well as trigger the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 351, + [ { "lineno": 418, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is triggered before a `get()` operation.", @@ -997,7 +1095,7 @@ "Object" ], "doc": "The item to be inserted instead of the original item specified by the caller.\n Returning a rejected promise will block the operation and will return a rejected promise to the caller as well as trigger the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 386, + [ { "lineno": 453, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is triggered before an `insert()` operation.", @@ -1130,7 +1228,7 @@ "wix-data.WixDataQuery" ], "doc": "The query to use instead of the original query specified by the caller.\n Returning a rejected promise will block the operation and will return a rejected promise to the operation caller as well as trigger the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 425, + [ { "lineno": 492, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is triggered before a `find()` operation.", @@ -1232,7 +1330,7 @@ "string" ], "doc": "The ID to be used for the [`remove()`](wix-data.html#remove) instead of the original `itemId` specified by the caller.\n Returning a rejected promise will block the operation and will return a rejected promise to the caller as well as trigger the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 466, + [ { "lineno": 533, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is called before a `remove()` operation.", @@ -1331,7 +1429,7 @@ "Object" ], "doc": "The item to be updated instead of the original item specified by the caller.\n Returning a rejected promise will block the operation and will return a rejected promise to the caller as well as trigger the [`onFailure()`](#onFailure) hook." }, "locations": - [ { "lineno": 504, + [ { "lineno": 571, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is triggered before an `update()` operation.", @@ -1434,7 +1532,7 @@ [ "Object" ] }, "doc": "Fulfilled - Returning a fulfilled promise will result in a fulfilled data operation with the provided result.\nRejected - Returning a rejected promise will result in returning a rejected promise to the caller of the data operation." }, "locations": - [ { "lineno": 541, + [ { "lineno": 608, "filename": "hooks.js" } ], "docs": { "summary": "A hook that is triggered on any error or rejected Promise from any of the wix-data operations.", diff --git a/wix-data/wix-data/WixDataDistinct.service.json b/wix-data/wix-data/WixDataDistinct.service.json new file mode 100644 index 0000000000..9c39a07860 --- /dev/null +++ b/wix-data/wix-data/WixDataDistinct.service.json @@ -0,0 +1,321 @@ +{ "name": "WixDataDistinct", + "memberOf": "wix-data", + "mixes": + [ "wix-data.WixDataFilter" ], + "labels": + [ "new" ], + "location": + { "lineno": 1, + "filename": "distinct.js" }, + "docs": + { "summary": "Provides functionality for refining a distinct data query.", + "description": + [ "The `WixDataDistinct` methods allow you to run, sort, filter, and control the results of a distinct query.", + "", + "When you run a query with the [`distinct()`](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-query/distinct) method, the query only returns distinct items. For example, the following code queries a collection for customers over the age of 20 and logs their last names in ascending order, without duplicates:", + "", + "", + " ```javascript", + " import wixData from 'wix-data';", + "", + " wixData.query(\"customers\")", + " .gt(\"age\", 20)", + " .distinct(\"lastName\")", + " .then((results) => {", + " console.log(results.items);", + " });", + " ```", + "", + " You can then further refine the distinct query by calling `WixDataDistinct` methods in the [`beforeDistinct()`](ADDLINK) hook." ], + "links": [], + "examples": [], + "extra": + { } }, + "properties": [], + "operations": + [ { "name": "ascending", + "labels": [], + "nameParams": [], + "params": [], + "ret": + { "type": "wix-data.WixDataDistinct", + "doc": "The distinct query object." }, + "locations": + [ { "lineno": 92, + "filename": "distinct.js" }, + { "lineno": 10, + "filename": "sortMixin.js" } ], + "docs": + { "summary": "Sorts the results of the distinct query in ascending order based on the distinct property name.", + "description": + [ "The `ascending()` method sorts the distinct query in ascending order based on the distinct property name." ], + "links": [], + "examples": + [ { "title": "Sort the results of the distinct query in ascending order", + "body": + [ "// Sort the results of the distinct query in ascending order", + "//" ], + "extra": + { } } ], + "extra": + { } }, + "extra": + { } }, + { "name": "descending", + "labels": [], + "nameParams": [], + "params": [], + "ret": + { "type": "wix-data.WixDataDistinct", + "doc": "The distinct query object." }, + "locations": + [ { "lineno": 116, + "filename": "distinct.js" }, + { "lineno": 41, + "filename": "sortMixin.js" } ], + "docs": + { "summary": "Sorts the results of the distinct query in descending order based on the distinct property name.", + "description": + [ "The `descending()` method sorts the distinct query in descending order based on the distinct property name." ], + "links": [], + "examples": + [ { "title": "Sort the results of the distinct query in descending order", + "body": + [ "// Sort the results of the distinct query in descending order", + "//" ], + "extra": + { } } ], + "extra": + { } }, + "extra": + { } }, + { "name": "filter", + "labels": [], + "nameParams": [], + "params": + [ { "name": "filter", + "type": "WixDataFilter", + "doc": "Filter to refine the distinct query." } ], + "ret": + { "type": "wix-data.WixDataDistinct", + "doc": "The distinct query object." }, + "locations": + [ { "lineno": 41, + "filename": "distinct.js" } ], + "docs": + { "summary": "Sets the filter used to refine the distinct query.", + "description": + [ "The `filter()` method defines the filter used to refine the distinct query." ], + "links": [], + "examples": + [ { "title": "Set the distinct query filter", + "body": + [ "// Set the distinct query filter" ], + "extra": + { } } ], + "extra": + { } }, + "extra": + { } }, + { "name": "getFilter", + "labels": [], + "nameParams": [], + "params": [], + "ret": + { "type": "wix-data.WixDataFilter", + "doc": "The filter used to refine the distinct query." }, + "locations": + [ { "lineno": 29, + "filename": "distinct.js" } ], + "docs": + { "summary": "Returns the filter used to refine the distinct query.", + "description": + [ "The `getFilter()` method returns a [`WixDataFilter()`](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-filter/introduction) that was used to refine the distinct query." ], + "links": [], + "examples": + [ { "title": "Get the distinct query filter", + "body": + [ "let filter = distinctQuery.getFilter();" ], + "extra": + { } } ], + "extra": + { } }, + "extra": + { } }, + { "name": "getPropertyName", + "labels": [], + "nameParams": [], + "params": [], + "ret": + { "type": "string", + "doc": "The property used to define the distinct query." }, + "locations": + [ { "lineno": 54, + "filename": "distinct.js" } ], + "docs": + { "summary": "Returns the name of the property used to define the distinct query.", + "description": + [ "The `getPropertyName()` method returns the name of the property used to define the distinct query." ], + "links": [], + "examples": + [ { "title": "Get the distinct property", + "body": + [ "// GET PROPERTY NAME let filter = distinctQuery.getFilter();" ], + "extra": + { } } ], + "extra": + { } }, + "extra": + { } }, + { "name": "isAscending", + "labels": [], + "nameParams": [], + "params": [], + "ret": + { "type": "boolean", + "doc": "Whether the results of the distinct query are sorted in ascending order." }, + "locations": + [ { "lineno": 80, + "filename": "distinct.js" } ], + "docs": + { "summary": "Whether the results of the distinct query are sorted in ascending order.", + "description": + [ "The `isAscending()` method returns `true` if the results of the distinct query are sorted in ascending order based on the distinct property." ], + "links": [], + "examples": + [ { "title": "Check whether the results of the distinct property are sorted in ascending order", + "body": + [ "// Check whether the results of the distinct property are sorted in ascending order" ], + "extra": + { } } ], + "extra": + { } }, + "extra": + { } }, + { "name": "isDescending", + "labels": [], + "nameParams": [], + "params": [], + "ret": + { "type": "boolean", + "doc": "Whether the results of the distinct query are sorted in descending order." }, + "locations": + [ { "lineno": 104, + "filename": "distinct.js" } ], + "docs": + { "summary": "Whether the results of the distinct query are sorted in descending order.", + "description": + [ "The `isDescending()` method returns `true` if the results of the distinct query are sorted in ascending order based on the distinct property." ], + "links": [], + "examples": + [ { "title": "Check if the results of the distinct property are sorted in descending order", + "body": + [ "// Check if the results of the distinct property are sorted in descending order", + "//" ], + "extra": + { } } ], + "extra": + { } }, + "extra": + { } }, + { "name": "limit", + "labels": [], + "nameParams": [], + "params": + [ { "name": "limit", + "type": "number", + "doc": "Number of items to return, which is also the [`pageSize`](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-result/page-size) of the results object." } ], + "ret": + { "type": "wix-data.WixDataDistinct", + "doc": "A [`WixDataDistinct`](ADDLINK) object representing the refined distinct query." }, + "locations": + [ { "lineno": 128, + "filename": "distinct.js" } ], + "docs": + { "summary": "Limits the number of items the distinct query returns.", + "description": + [ "The `limit()` method defines the number of results a distinct query returns in each page. Only one page of results is retrieved at a time. use the [`next()`](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-result/next) and [`prev()`](https://dev.wix.com/docs/sdk/backend-modules/data/items/wix-data-result/prev) methods to navigate the pages of a query result.", + "", + " By default, `limit` is set to `50`.", + "", + " The maximum value that `limit()` can accept is `1000`.", + "", + " > **Note** : For some [Wix app collections](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/collections/working-with-wix-app-collections-and-code), the maximum value `limit()` can accept is less than `1000`. For example, the maximum limit for the Wix `Stores/Product` collection is 100." ], + "links": [], + "examples": + [ { "title": "Add a limit to a distinct query", + "body": + [ "// Add a limit to a distinct query", + "// let filter = distinctQuery.getFilter();" ], + "extra": + { } } ], + "extra": + { } }, + "extra": + { } }, + { "name": "propertyName", + "labels": [], + "nameParams": [], + "params": + [ { "name": "newPropertyName", + "type": "string", + "doc": "Property by which to return distinct values, without duplicates." } ], + "ret": + { "type": "wix-data.WixDataDistinct", + "doc": "The distinct query object." }, + "locations": + [ { "lineno": 66, + "filename": "distinct.js" } ], + "docs": + { "summary": "Sets the property name by which to return distinct values.", + "description": + [ "The `propertyName()` method defines the property by which to return distinct values, without duplicates." ], + "links": [], + "examples": + [ { "title": "Set the distinct property", + "body": + [ "// Set the distinct property", + "// let filter = distinctQuery.getFilter();" ], + "extra": + { } } ], + "extra": + { } }, + "extra": + { } }, + { "name": "skip", + "labels": [], + "nameParams": [], + "params": + [ { "name": "skip", + "type": "number", + "doc": "Number of items to skip in before returning the distinct query results." } ], + "ret": + { "type": "wix-data.WixDataDistinct", + "doc": "A `WixDataDistinct` object representing the refined query." }, + "locations": + [ { "lineno": 146, + "filename": "distinct.js" } ], + "docs": + { "summary": "Sets the number of items to skip before returning distinct query results.", + "description": + [ "The `skip()` method defines the number of query results to skip before returning the remaining results.", + "", + " For example, if you query a collection and 50 items match your query, but you set `skip` to 10, the results skip the first 10 items that match and return the 11th through 50th items.", + "", + " By default, `skip` is set to 0." ], + "links": [], + "examples": + [ { "title": "Add a skip to a distinct query", + "body": + [ "// Add a skip to a distinct query", + "//" ], + "extra": + { } } ], + "extra": + { } }, + "extra": + { } } ], + "callbacks": [], + "messages": [], + "extra": + { } } \ No newline at end of file