getDataCollection( )


Retrieves a data collection by ID.

Permissions
Manage Data Collections
Learn more about app permissions.
Method Declaration
Copy
function getDataCollection(
  dataCollectionId: string,
  options: GetDataCollectionOptions,
): Promise<DataCollection>;
Method Parameters
dataCollectionIdstringRequired

ID of the collection to retrieve.


optionsGetDataCollectionOptions

Options for retrieving a data collection.

Returns
Return Type:Promise<DataCollection>
JavaScript
import { collections } from "wix-data.v2"; /* Retrieving a collection with an _id of "myMusicCollection" * * Sample dataCollectionId value: * const dataCollectionId = "myMusicCollection" */ export async function myGetDataCollectionFunction(dataCollectionId) { try { const retrievedCollection = await collections.getDataCollection(dataCollectionId); return retrievedCollection; } catch (error) { console.error(error); // Handle the error } } /* Returns a promise that resolves to the retrieved collection: * { * "_id": "myMusicCollection", * "collectionType": "NATIVE", * "displayName": "My Music Collection", * "displayField": "myMusicCollection", * "capabilities": { * "dataOperations": [ * "IS_REFERENCED", * "INSERT", * "SAVE", * "BULK_INSERT", * "BULK_UPDATE", * "UPDATE", * "TRUNCATE", * "REMOVE", * "REMOVE_REFERENCE", * "COUNT", * "FIND", * "REPLACE_REFERENCES", * "BULK_REMOVE", * "INSERT_REFERENCE", * "GET", * "BULK_SAVE", * "QUERY_REFERENCED", * "DISTINCT", * "AGGREGATE" * ], * "collectionOperations": [ * "UPDATE", * "REMOVE" * ], * "indexLimits": { * "regular": 3, * "unique": 1, * "total": 4 * } * }, * "fields": * [ * { * "key": "artist", * "displayName": "Artist Name", * "type": "TEXT", * "systemField": false, * "capabilities": { * "sortable": true, * "queryOperators": [ * "EQ", * "LT", * "GT", * "NE", * "LTE", * "GTE", * "STARTS_WITH", * "ENDS_WITH", * "CONTAINS", * "HAS_SOME", * "HAS_ALL", * "EXISTS", * "URLIZED" * ] * }, * "encrypted": false, * "description": "The artist's name" * }, * { * "key": "_id", * "displayName": "ID", * "type": "TEXT", * "systemField": true, * "capabilities": { * "sortable": true, * "queryOperators": [ * "EQ", * "LT", * "GT", * "NE", * "LTE", * "GTE", * "STARTS_WITH", * "ENDS_WITH", * "CONTAINS", * "HAS_SOME", * "HAS_ALL", * "EXISTS", * "URLIZED" * ] * }, * "encrypted": false * }, * { * "key": "_createdDate", * "displayName": "Created Date", * "type": "DATETIME", * "systemField": true, * "capabilities": { * "sortable": true, * "queryOperators": [ * "EQ", * "LT", * "GT", * "NE", * "LTE", * "GTE", * "STARTS_WITH", * "ENDS_WITH", * "CONTAINS", * "HAS_SOME", * "HAS_ALL", * "EXISTS", * "URLIZED" * ] * }, * "encrypted": false * }, * { * "key": "_updatedDate", * "displayName": "Updated Date", * "type": "DATETIME", * "systemField": true, * "capabilities": { * "sortable": true, * "queryOperators": [ * "EQ", * "LT", * "GT", * "NE", * "LTE", * "GTE", * "STARTS_WITH", * "ENDS_WITH", * "CONTAINS", * "HAS_SOME", * "HAS_ALL", * "EXISTS", * "URLIZED" * ] * }, * "encrypted": false * }, * { * "key": "_owner", * "displayName": "Owner", * "type": "TEXT", * "systemField": true, * "capabilities": { * "sortable": true, * "queryOperators": [ * "EQ", * "LT", * "GT", * "NE", * "LTE", * "GTE", * "STARTS_WITH", * "ENDS_WITH", * "CONTAINS", * "HAS_SOME", * "HAS_ALL", * "EXISTS", * "URLIZED" * ] * }, * "encrypted": false * } * ], * "permissions": { * "insert": "SITE_MEMBER_AUTHOR", * "update": "SITE_MEMBER_AUTHOR", * "remove": "SITE_MEMBER_AUTHOR", * "read": "ANYONE" * }, * "revision": "1", * "plugins": [], * "pagingModes": [ * "OFFSET" * ], * "_createdDate": "2023-07-19T12:40:02.372Z", * "_updatedDate": "2023-07-19T12:40:02.372Z" * }; */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?