Search.../

listDataCollections( )

Developer Preview

Retrieves a list of all data collections associated with the site or project.

Description

By default, the list is ordered by ID in ascending order.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function listDataCollections(options: ListDataCollectionsOptions): Promise<ListDataCollectionsResponse>

listDataCollections Parameters

NAME
TYPE
DESCRIPTION
options
Optional
ListDataCollectionsOptions

Options for retrieving a list of data collections.

Returns

Return Type:

Promise<
ListDataCollectionsResponse
>
NAME
TYPE
DESCRIPTION
collections
Array<
DataCollection
>

List of collections.

pagingMetadata
PagingMetadataV2

Paging information.

Was this helpful?

Lists existing collections (dashboard page code)

Copy Code
1import { collections } from "wix-data.v2";
2
3export async function myListDataCollectionsFunction(options) {
4 try {
5 const myDataCollections = await collections.listDataCollections();
6 return myDataCollections;
7 } catch (error) {
8 console.error(error);
9 // Handle the error
10 }
11}
12
13/* Returns a promise that resolves to a list of existing data collections:
14* {
15* "collections": [
16* // ...
17* {
18* "_id": "myMusicCollection",
19* "collectionType": "NATIVE",
20* "displayName": "My Music Collection",
21* "displayField": "myMusicCollection",
22* "capabilities": {
23* "dataOperations": [
24* "IS_REFERENCED",
25* "INSERT",
26* "SAVE",
27* "BULK_INSERT",
28* "BULK_UPDATE",
29* "UPDATE",
30* "TRUNCATE",
31* "REMOVE",
32* "REMOVE_REFERENCE",
33* "COUNT",
34* "FIND",
35* "REPLACE_REFERENCES",
36* "BULK_REMOVE",
37* "INSERT_REFERENCE",
38* "GET",
39* "BULK_SAVE",
40* "QUERY_REFERENCED",
41* "DISTINCT",
42* "AGGREGATE"
43* ],
44* "collectionOperations": [
45* "UPDATE",
46* "REMOVE"
47* ],
48* "indexLimits": {
49* "regular": 3,
50* "unique": 1,
51* "total": 4
52* }
53* },
54* "fields":
55* [
56* {
57* "key": "artist",
58* "displayName": "Artist Name",
59* "type": "TEXT",
60* "systemField": false,
61* "capabilities": {
62* "sortable": true,
63* "queryOperators": [
64* "EQ",
65* "LT",
66* "GT",
67* "NE",
68* "LTE",
69* "GTE",
70* "STARTS_WITH",
71* "ENDS_WITH",
72* "CONTAINS",
73* "HAS_SOME",
74* "HAS_ALL",
75* "EXISTS",
76* "URLIZED"
77* ]
78* },
79* "encrypted": false,
80* "description": "The artist's name"
81* },
82* {
83* "key": "_id",
84* "displayName": "ID",
85* "type": "TEXT",
86* "systemField": true,
87* "capabilities": {
88* "sortable": true,
89* "queryOperators": [
90* "EQ",
91* "LT",
92* "GT",
93* "NE",
94* "LTE",
95* "GTE",
96* "STARTS_WITH",
97* "ENDS_WITH",
98* "CONTAINS",
99* "HAS_SOME",
100* "HAS_ALL",
101* "EXISTS",
102* "URLIZED"
103* ]
104* },
105* "encrypted": false
106* },
107* // Additional system fields ...
108* ],
109* "permissions": {
110* "insert": "SITE_MEMBER_AUTHOR",
111* "update": "SITE_MEMBER_AUTHOR",
112* "remove": "SITE_MEMBER_AUTHOR",
113* "read": "ANYONE"
114* },
115* "revision": "1",
116* "plugins": [
117* {
118* "type": "GRIDAPPLESS",
119* "gridapplessOptions": {
120* "migrated": true
121* }
122* }
123* ],
124* "pagingModes": [
125* "OFFSET"
126* ],
127* "_createdDate": "2023-07-19T12:40:02.372Z",
128* "_updatedDate": "2023-07-19T12:40:02.372Z"
129* }
130* ],
131* "pagingMetadata": {
132* "count": 18,
133* "offset": 0,
134* "total": 18,
135* "tooManyToCount": false
136* }
137* };
138* */
Lists existing collections (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { collections } from 'wix-data.v2';
3
4export const myListDataCollectionsFunction = webMethod(Permissions.Anyone, async (options) => {
5 try {
6 const myDataCollections = await collections.listDataCollections();
7 return myDataCollections;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12});
13
14/* Returns a promise that resolves to a list of existing data collections:
15* {
16* "collections": [
17* // ...
18* {
19* "_id": "myMusicCollection",
20* "collectionType": "NATIVE",
21* "displayName": "My Music Collection",
22* "displayField": "myMusicCollection",
23* "capabilities": {
24* "dataOperations": [
25* "IS_REFERENCED",
26* "INSERT",
27* "SAVE",
28* "BULK_INSERT",
29* "BULK_UPDATE",
30* "UPDATE",
31* "TRUNCATE",
32* "REMOVE",
33* "REMOVE_REFERENCE",
34* "COUNT",
35* "FIND",
36* "REPLACE_REFERENCES",
37* "BULK_REMOVE",
38* "INSERT_REFERENCE",
39* "GET",
40* "BULK_SAVE",
41* "QUERY_REFERENCED",
42* "DISTINCT",
43* "AGGREGATE"
44* ],
45* "collectionOperations": [
46* "UPDATE",
47* "REMOVE"
48* ],
49* "indexLimits": {
50* "regular": 3,
51* "unique": 1,
52* "total": 4
53* }
54* },
55* "fields":
56* [
57* {
58* "key": "artist",
59* "displayName": "Artist Name",
60* "type": "TEXT",
61* "systemField": false,
62* "capabilities": {
63* "sortable": true,
64* "queryOperators": [
65* "EQ",
66* "LT",
67* "GT",
68* "NE",
69* "LTE",
70* "GTE",
71* "STARTS_WITH",
72* "ENDS_WITH",
73* "CONTAINS",
74* "HAS_SOME",
75* "HAS_ALL",
76* "EXISTS",
77* "URLIZED"
78* ]
79* },
80* "encrypted": false,
81* "description": "The artist's name"
82* },
83* {
84* "key": "_id",
85* "displayName": "ID",
86* "type": "TEXT",
87* "systemField": true,
88* "capabilities": {
89* "sortable": true,
90* "queryOperators": [
91* "EQ",
92* "LT",
93* "GT",
94* "NE",
95* "LTE",
96* "GTE",
97* "STARTS_WITH",
98* "ENDS_WITH",
99* "CONTAINS",
100* "HAS_SOME",
101* "HAS_ALL",
102* "EXISTS",
103* "URLIZED"
104* ]
105* },
106* "encrypted": false
107* },
108* // Additional system fields ...
109* ],
110* "permissions": {
111* "insert": "SITE_MEMBER_AUTHOR",
112* "update": "SITE_MEMBER_AUTHOR",
113* "remove": "SITE_MEMBER_AUTHOR",
114* "read": "ANYONE"
115* },
116* "revision": "1",
117* "plugins": [
118* {
119* "type": "GRIDAPPLESS",
120* "gridapplessOptions": {
121* "migrated": true
122* }
123* }
124* ],
125* "pagingModes": [
126* "OFFSET"
127* ],
128* "_createdDate": "2023-07-19T12:40:02.372Z",
129* "_updatedDate": "2023-07-19T12:40:02.372Z"
130* }
131* ],
132* "pagingMetadata": {
133* "count": 18,
134* "offset": 0,
135* "total": 18,
136* "tooManyToCount": false
137* }
138* };
139* */
140
List up to 10 existing data collections with a given offest

Copy Code
1import { Permissions, webMethod } from "wix-web-module";
2import { collections } from "wix-data.v2";
3
4/* Sample options parameter:
5 *
6 * const options = {
7 * paging: {
8 * limit: 10,
9 * offset: 1
10 * }
11 * };
12 */
13
14export const myListDataCollectionsFunctionAdv = webMethod(Permissions.Anyone, async (options) => {
15 try {
16 const ListDataCollectionsResponse = await collections.listDataCollections(options);
17 return ListDataCollectionsResponse;
18 } catch (error) {
19 console.error(error);
20 // Handle the error
21 }
22});
23
24/* Returns a promise that resolves to a list of existing data collections:
25 * {
26 * "collections": [
27 * ...
28 * // List of collections, starting with the second collection
29 * ...
30 * {
31 * "_id": "Members/FullData",
32 * "collectionType": "WIX_APP",
33 * "ownerAppId": "14cc59bc-f0b7-15b8-e1c7-89ce41d0e0c9",
34 * "displayName": "FullData",
35 * "defaultDisplayOrder": {
36 * "fieldKey": "_createdDate",
37 * "direction": "ASC"
38 * },
39 * "displayNamespace": "Members",
40 * "displayField": "loginEmail",
41 * "capabilities": {
42 * "dataOperations": [
43 * "UPDATE",
44 * "REMOVE",
45 * "COUNT",
46 * "FIND",
47 * "GET"
48 * ],
49 * "collectionOperations": []
50 * },
51 * "fields":
52 * [
53 * {
54 * "key": "_id",
55 * "displayName": "ID",
56 * "type": "TEXT",
57 * "systemField": true,
58 * "capabilities": {
59 * "sortable": false,
60 * "queryOperators": [
61 * "EQ",
62 * "HAS_SOME",
63 * "CONTAINS",
64 * "URLIZED"
65 * ]
66 * },
67 * "encrypted": false
68 * },
69 * {
70 * "key": "loginEmail",
71 * "displayName": "Login Email",
72 * "type": "TEXT",
73 * "systemField": true,
74 * "capabilities": {
75 * "sortable": false,
76 * "queryOperators": [
77 * "EQ",
78 * "HAS_SOME",
79 * "CONTAINS"
80 * ]
81 * },
82 * "encrypted": false
83 * },
84 * {
85 * "key": "firstName",
86 * "displayName": "First Name",
87 * "type": "TEXT",
88 * "systemField": false,
89 * "capabilities": {
90 * "sortable": true,
91 * "queryOperators": [
92 * "EQ",
93 * "HAS_SOME",
94 * "CONTAINS"
95 * ]
96 * },
97 * "encrypted": false
98 * },
99 * {
100 * "key": "lastName",
101 * "displayName": "Last Name",
102 * "type": "TEXT",
103 * "systemField": false,
104 * "capabilities": {
105 * "sortable": true,
106 * "queryOperators": [
107 * "EQ",
108 * "HAS_SOME",
109 * "CONTAINS"
110 * ]
111 * },
112 * "encrypted": false
113 * },
114 * {
115 * "key": "phone",
116 * "displayName": "Phone",
117 * "type": "TEXT",
118 * "systemField": true,
119 * "capabilities": {
120 * "sortable": false,
121 * "queryOperators": []
122 * },
123 * "encrypted": false
124 * },
125 * {
126 * "key": "email",
127 * "displayName": "Email",
128 * "type": "TEXT",
129 * "systemField": true,
130 * "capabilities": {
131 * "sortable": false,
132 * "queryOperators": []
133 * },
134 * "encrypted": false
135 * },
136 * {
137 * "key": "nickname",
138 * "displayName": "Nickname",
139 * "type": "TEXT",
140 * "systemField": false,
141 * "capabilities": {
142 * "sortable": true,
143 * "queryOperators": [
144 * "EQ",
145 * "HAS_SOME",
146 * "CONTAINS"
147 * ]
148 * },
149 * "encrypted": false
150 * },
151 * {
152 * "key": "slug",
153 * "displayName": "Slug",
154 * "type": "TEXT",
155 * "systemField": true,
156 * "capabilities": {
157 * "sortable": false,
158 * "queryOperators": [
159 * "EQ"
160 * ]
161 * },
162 * "encrypted": false
163 * },
164 * {
165 * "key": "profilePhoto",
166 * "displayName": "Profile Photo",
167 * "type": "IMAGE",
168 * "systemField": false,
169 * "capabilities": {
170 * "sortable": false,
171 * "queryOperators": []
172 * },
173 * "encrypted": false
174 * },
175 * {
176 * "key": "coverPhoto",
177 * "displayName": "Cover Photo",
178 * "type": "IMAGE",
179 * "systemField": false,
180 * "capabilities": {
181 * "sortable": false,
182 * "queryOperators": []
183 * },
184 * "encrypted": false
185 * },
186 * {
187 * "key": "status",
188 * "displayName": "Status",
189 * "type": "TEXT",
190 * "systemField": true,
191 * "capabilities": {
192 * "sortable": false,
193 * "queryOperators": []
194 * },
195 * "encrypted": false
196 * },
197 * {
198 * "key": "privacyStatus",
199 * "displayName": "Privacy Status",
200 * "type": "TEXT",
201 * "systemField": true,
202 * "capabilities": {
203 * "sortable": false,
204 * "queryOperators": []
205 * },
206 * "encrypted": false
207 * },
208 * {
209 * "key": "activityStatus",
210 * "displayName": "Activity Status",
211 * "type": "TEXT",
212 * "systemField": true,
213 * "capabilities": {
214 * "sortable": false,
215 * "queryOperators": []
216 * },
217 * "encrypted": false
218 * },
219 * {
220 * "key": "lastLoginDate",
221 * "displayName": "Last Login Date",
222 * "type": "DATETIME",
223 * "systemField": true,
224 * "capabilities": {
225 * "sortable": true,
226 * "queryOperators": []
227 * },
228 * "encrypted": false
229 * },
230 * {
231 * "key": "_createdDate",
232 * "displayName": "Creation Date",
233 * "type": "DATETIME",
234 * "systemField": true,
235 * "capabilities": {
236 * "sortable": true,
237 * "queryOperators": []
238 * },
239 * "encrypted": false
240 * },
241 * {
242 * "key": "_updatedDate",
243 * "displayName": "Last Updated",
244 * "type": "DATETIME",
245 * "systemField": true,
246 * "capabilities": {
247 * "sortable": false,
248 * "queryOperators": []
249 * },
250 * "encrypted": false
251 * }
252 * ],
253 * "permissions": {
254 * "insert": "ADMIN",
255 * "update": "ADMIN",
256 * "remove": "ADMIN",
257 * "read": "ANYONE"
258 * },
259 * "revision": "0",
260 * "plugins": [],
261 * "pagingModes": [
262 * "OFFSET"
263 * ]
264 * }
265 * ],
266 * "pagingMetadata": {
267 * "count": 10,
268 * "offset": 1,
269 * "total": 18,
270 * "tooManyToCount": false
271 * }
272 * };
273 */
274