get( )


Retrieves an item from a collection.

The get() function returns a Promise that resolves to the item with ID itemId from the specified collection, or null if the itemId is not found. The Promise is rejected if the current user does not have read permissions for the collection.

If the specified collection contains reference fields, the ID of the referenced item is returned. To return the values of the referenced items use query() and include().

If the get() function is passed the ID of a hidden item, it returns null.

Calling the get() function triggers the beforeGet() and afterGet() hooks if they have been defined.

Use the options parameter to run get() from backend code without checking for permissions or without its registered hooks.

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 for more information. To solve this problem, you can use the setTimeout() function to delay retrieving data following any changes to your database collection.
  • An itemId is required to retrieve an item even from a single-item collection.
Method Declaration
Copy
Method Parameters
collectionIdstringRequired

The ID of the collection to retrieve the item from.

To find your collectionId, select the Databases tab in the Velo Sidebar. Hover over your collection, click the three dots, and select Edit Settings.


itemIdstringRequired

The ID of the item to retrieve.


optionsWixDataOptions

An object containing options to use when processing this operation.

Returns
Return Type:Promise<object>
Did this help?