Search.../

items

Returns the items that match the query.

Description

The current page of items retrieved by the query.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

When no items match the query, the items array is empty.

Type:

Array<Object>Read Only

Was this helpful?

Get the items of a query result

Copy Code
1let items = results.items;
2
3/*
4 * [
5 * {
6 * "_id": "1234",
7 * "_owner": "f45jf8d2-grkj-2opd-4ovk-9rfj4wo5tvj3",
8 * "_createdDate": "2017-05-29T08:35:52.344Z",
9 * "_updatedDate": "2017-05-29T08:35:52.344Z",
10 * "title": "Dr.",
11 * "first_name": "Jane",
12 * "last_name": "Doe",
13 * "status": "active"
14 * },
15 * {
16 * "_id": "5678",
17 * "_owner": "f45jf8d2-grkj-2opd-4ovk-9rfj4wo5tvj3",
18 * "_createdDate": "2017-05-25T12:48:56.572Z",
19 * "_updatedDate": "2017-05-29T07:30:15.869Z",
20 * "title": "Mr.",
21 * "first_name": "John",
22 * "last_name": "Doe",
23 * "status": "active"
24 * }
25 * ]
26 */
Perform a query and get the items of the result

Copy Code
1import wixData from 'wix-data';
2
3// ...
4
5wixData.query("myCollection")
6 .find()
7 .then((results) => {
8 if(results.items.length > 0) {
9 let items = results.items; // see below
10 } else {
11 // handle case where no matching items found
12 }
13 }) ;
14
15/* items:
16 *
17 * [
18 * {
19 * "_id": "1234",
20 * "_owner": "f45jf8d2-grkj-2opd-4ovk-9rfj4wo5tvj3",
21 * "_createdDate": "2017-05-29T08:35:52.344Z",
22 * "_updatedDate": "2017-05-29T08:35:52.344Z",
23 * "title": "Dr.",
24 * "first_name": "Jane",
25 * "last_name": "Doe",
26 * "status": "active"
27 * },
28 * {
29 * "_id": "5678",
30 * "_owner": "f45jf8d2-grkj-2opd-4ovk-9rfj4wo5tvj3",
31 * "_createdDate": "2017-05-25T12:48:56.572Z",
32 * "_updatedDate": "2017-05-29T07:30:15.869Z",
33 * "title": "Mr.",
34 * "first_name": "John",
35 * "last_name": "Doe",
36 * "status": "active"
37 * }
38 * ]
39 */