getDataCollection( )
Retrieves a data collection by ID.
Syntax
function getDataCollection(dataCollectionId: string, options: GetDataCollectionOptions): Promise<DataCollection>
getDataCollection Parameters
NAME
TYPE
DESCRIPTION
ID of the collection to retrieve.
Options for retrieving a data collection.
Returns
Details of the collection requested.
Return Type:
NAME
TYPE
DESCRIPTION
Date the collection was created.
Collection ID. For example, my-first-collection
. May include a namespace.
Date the collection was last updated.
Capabilities the collection supports.
Collection type. Indicates how the collection was created and is stored.
NATIVE
: User-created collection.WIX_APP
: Collection created by a Wix app, including starter collections created when a Wix app is installed.BLOCKS_APP
: Collection created by a Wix Blocks app.EXTERNAL
: Collection located in externally connected storage.
Indicates how the collection's items are sorted by default when a query doesn't specify an order.
The field whose value the CMS displays to represent the collection item when referenced in a different collection.
Collection's display name as shown in the CMS. For example, My First Collection
.
UI-friendly namespace of the Wix app with which the data collection is associated, such as Stores or Bookings. Empty for all data collections not owned by internal Wix apps.
Collection's field structure.
Maximum number of items returned in a single query, based on the underlying storage. Native collections have a maximum page size of 1000 for offset-based queries or 100 for cursor-based queries. External collections' maximum page size defaults to 50, but an external provider can set any maximum value up to 1000.
ID of the app that defined this collection. For user-defined collections, this value is null.
All paging modes the collection supports. In native collections, offset-based paging is supported by default.
Levels of permission for accessing and modifying data, defined by lowest role needed to perform each action.
All plugins the collection uses. Plugins apply additional capabilities to the collection or extend its functionality.
Collection's current revision number, which increments each time the collection is updated. For an update operation to succeed, you must pass the latest revision number.
Was this helpful?
1import { collections } from "wix-data.v2";23/* Retrieving a collection with an _id of "myMusicCollection"4 *5 * Sample dataCollectionId value:6 * const dataCollectionId = "myMusicCollection"7 */89export async function myGetDataCollectionFunction(dataCollectionId) {10 try {11 const retrievedCollection = await collections.getDataCollection(dataCollectionId)12 return retrievedCollection;13 } catch (error) {14 console.error(error);15 // Handle the error16 }17}1819/* Returns a promise that resolves to the retrieved collection:20* {21* "_id": "myMusicCollection",22* "collectionType": "NATIVE",23* "displayName": "My Music Collection",24* "displayField": "myMusicCollection",25* "capabilities": {26* "dataOperations": [27* "IS_REFERENCED",28* "INSERT",29* "SAVE",30* "BULK_INSERT",31* "BULK_UPDATE",32* "UPDATE",33* "TRUNCATE",34* "REMOVE",35* "REMOVE_REFERENCE",36* "COUNT",37* "FIND",38* "REPLACE_REFERENCES",39* "BULK_REMOVE",40* "INSERT_REFERENCE",41* "GET",42* "BULK_SAVE",43* "QUERY_REFERENCED",44* "DISTINCT",45* "AGGREGATE"46* ],47* "collectionOperations": [48* "UPDATE",49* "REMOVE"50* ],51* "indexLimits": {52* "regular": 3,53* "unique": 1,54* "total": 455* }56* },57* "fields":58* [59* {60* "key": "artist",61* "displayName": "Artist Name",62* "type": "TEXT",63* "systemField": false,64* "capabilities": {65* "sortable": true,66* "queryOperators": [67* "EQ",68* "LT",69* "GT",70* "NE",71* "LTE",72* "GTE",73* "STARTS_WITH",74* "ENDS_WITH",75* "CONTAINS",76* "HAS_SOME",77* "HAS_ALL",78* "EXISTS",79* "URLIZED"80* ]81* },82* "encrypted": false,83* "description": "The artist's name"84* },85* {86* "key": "_id",87* "displayName": "ID",88* "type": "TEXT",89* "systemField": true,90* "capabilities": {91* "sortable": true,92* "queryOperators": [93* "EQ",94* "LT",95* "GT",96* "NE",97* "LTE",98* "GTE",99* "STARTS_WITH",100* "ENDS_WITH",101* "CONTAINS",102* "HAS_SOME",103* "HAS_ALL",104* "EXISTS",105* "URLIZED"106* ]107* },108* "encrypted": false109* },110* {111* "key": "_createdDate",112* "displayName": "Created Date",113* "type": "DATETIME",114* "systemField": true,115* "capabilities": {116* "sortable": true,117* "queryOperators": [118* "EQ",119* "LT",120* "GT",121* "NE",122* "LTE",123* "GTE",124* "STARTS_WITH",125* "ENDS_WITH",126* "CONTAINS",127* "HAS_SOME",128* "HAS_ALL",129* "EXISTS",130* "URLIZED"131* ]132* },133* "encrypted": false134* },135* {136* "key": "_updatedDate",137* "displayName": "Updated Date",138* "type": "DATETIME",139* "systemField": true,140* "capabilities": {141* "sortable": true,142* "queryOperators": [143* "EQ",144* "LT",145* "GT",146* "NE",147* "LTE",148* "GTE",149* "STARTS_WITH",150* "ENDS_WITH",151* "CONTAINS",152* "HAS_SOME",153* "HAS_ALL",154* "EXISTS",155* "URLIZED"156* ]157* },158* "encrypted": false159* },160* {161* "key": "_owner",162* "displayName": "Owner",163* "type": "TEXT",164* "systemField": true,165* "capabilities": {166* "sortable": true,167* "queryOperators": [168* "EQ",169* "LT",170* "GT",171* "NE",172* "LTE",173* "GTE",174* "STARTS_WITH",175* "ENDS_WITH",176* "CONTAINS",177* "HAS_SOME",178* "HAS_ALL",179* "EXISTS",180* "URLIZED"181* ]182* },183* "encrypted": false184* }185* ],186* "permissions": {187* "insert": "SITE_MEMBER_AUTHOR",188* "update": "SITE_MEMBER_AUTHOR",189* "remove": "SITE_MEMBER_AUTHOR",190* "read": "ANYONE"191* },192* "revision": "1",193* "plugins": [194* {195* "type": "GRIDAPPLESS",196* "gridapplessOptions": {197* "migrated": true198* }199* }200* ],201* "pagingModes": [202* "OFFSET"203* ],204* "_createdDate": "2023-07-19T12:40:02.372Z",205* "_updatedDate": "2023-07-19T12:40:02.372Z"206* };207*/
1import { Permissions, webMethod } from "wix-web-module";2import { collections } from "wix-data.v2";34/* Retrieving a collection with an _id of "myMusicCollection"5 *6 * Sample dataCollectionId value:7 * const dataCollectionId = "myMusicCollection"8 */910export const myGetDataCollectionFunction = webMethod(Permissions.Anyone, async (dataCollectionId) => {11 try {12 const retrievedCollection = await collections.getDataCollection(dataCollectionId);13 return retrievedCollection;14 } catch (error) {15 console.error(error);16 // Handle the error17 }18});1920/* Returns a promise that resolves to the retrieved collection:21* {22* "_id": "myMusicCollection",23* "collectionType": "NATIVE",24* "displayName": "My Music Collection",25* "displayField": "myMusicCollection",26* "capabilities": {27* "dataOperations": [28* "IS_REFERENCED",29* "INSERT",30* "SAVE",31* "BULK_INSERT",32* "BULK_UPDATE",33* "UPDATE",34* "TRUNCATE",35* "REMOVE",36* "REMOVE_REFERENCE",37* "COUNT",38* "FIND",39* "REPLACE_REFERENCES",40* "BULK_REMOVE",41* "INSERT_REFERENCE",42* "GET",43* "BULK_SAVE",44* "QUERY_REFERENCED",45* "DISTINCT",46* "AGGREGATE"47* ],48* "collectionOperations": [49* "UPDATE",50* "REMOVE"51* ],52* "indexLimits": {53* "regular": 3,54* "unique": 1,55* "total": 456* }57* },58* "fields":59* [60* {61* "key": "artist",62* "displayName": "Artist Name",63* "type": "TEXT",64* "systemField": false,65* "capabilities": {66* "sortable": true,67* "queryOperators": [68* "EQ",69* "LT",70* "GT",71* "NE",72* "LTE",73* "GTE",74* "STARTS_WITH",75* "ENDS_WITH",76* "CONTAINS",77* "HAS_SOME",78* "HAS_ALL",79* "EXISTS",80* "URLIZED"81* ]82* },83* "encrypted": false,84* "description": "The artist's name"85* },86* {87* "key": "_id",88* "displayName": "ID",89* "type": "TEXT",90* "systemField": true,91* "capabilities": {92* "sortable": true,93* "queryOperators": [94* "EQ",95* "LT",96* "GT",97* "NE",98* "LTE",99* "GTE",100* "STARTS_WITH",101* "ENDS_WITH",102* "CONTAINS",103* "HAS_SOME",104* "HAS_ALL",105* "EXISTS",106* "URLIZED"107* ]108* },109* "encrypted": false110* },111* {112* "key": "_createdDate",113* "displayName": "Created Date",114* "type": "DATETIME",115* "systemField": true,116* "capabilities": {117* "sortable": true,118* "queryOperators": [119* "EQ",120* "LT",121* "GT",122* "NE",123* "LTE",124* "GTE",125* "STARTS_WITH",126* "ENDS_WITH",127* "CONTAINS",128* "HAS_SOME",129* "HAS_ALL",130* "EXISTS",131* "URLIZED"132* ]133* },134* "encrypted": false135* },136* {137* "key": "_updatedDate",138* "displayName": "Updated Date",139* "type": "DATETIME",140* "systemField": true,141* "capabilities": {142* "sortable": true,143* "queryOperators": [144* "EQ",145* "LT",146* "GT",147* "NE",148* "LTE",149* "GTE",150* "STARTS_WITH",151* "ENDS_WITH",152* "CONTAINS",153* "HAS_SOME",154* "HAS_ALL",155* "EXISTS",156* "URLIZED"157* ]158* },159* "encrypted": false160* },161* {162* "key": "_owner",163* "displayName": "Owner",164* "type": "TEXT",165* "systemField": true,166* "capabilities": {167* "sortable": true,168* "queryOperators": [169* "EQ",170* "LT",171* "GT",172* "NE",173* "LTE",174* "GTE",175* "STARTS_WITH",176* "ENDS_WITH",177* "CONTAINS",178* "HAS_SOME",179* "HAS_ALL",180* "EXISTS",181* "URLIZED"182* ]183* },184* "encrypted": false185* }186* ],187* "permissions": {188* "insert": "SITE_MEMBER_AUTHOR",189* "update": "SITE_MEMBER_AUTHOR",190* "remove": "SITE_MEMBER_AUTHOR",191* "read": "ANYONE"192* },193* "revision": "1",194* "plugins": [195* {196* "type": "GRIDAPPLESS",197* "gridapplessOptions": {198* "migrated": true199* }200* }201* ],202* "pagingModes": [203* "OFFSET"204* ],205* "_createdDate": "2023-07-19T12:40:02.372Z",206* "_updatedDate": "2023-07-19T12:40:02.372Z"207* };208*/