Appearance
Store Functions
Store functions check the state of user data stores. User stores are per-user collections that power features like favorites, bookmarks, and wishlists.
in_store
Checks if a specific item exists in a named store for the current user.
Signature: in_store(storeName, itemId)
| Parameter | Type | Description |
|---|---|---|
storeName | string | The store name (e.g., favorites, wishlist). |
itemId | string/number | The item ID to check. |
Returns true or false.
`{ {in_store('favorites', row.id) ? 'Favorited' : 'Add to Favorites'}}`Returns false if the user is not logged in or the store/item does not exist.
Use in visibility rules
Show an "unfavorite" button only if the item is in favorites:
in_store('favorites', row.id)Use in conditional styling
`{ {in_store('wishlist', row.id) ? 'btn-primary' : 'btn-outline'}}`How it works
The function queries the nexus_user_stores table:
sql
SELECT COUNT(*) FROM nexus_user_stores
WHERE user_id = ? AND store_name = ? AND item_id = ?The store name is sanitized (lowercase, alphanumeric + underscores).
count_store
Returns the total number of items in a named store for the current user.
Signature: count_store(storeName)
Returns a number (integer).
`{ {count_store('favorites')}}` favorites
// "12 favorites"
`{ {count_store('cart')}}` items in cart
// "3 items in cart"Returns 0 if the user is not logged in or the store is empty.
Use in badge displays
`{ {count_store('cart') > 0 ? count_store('cart') : ''}}`Show the count only if the cart is not empty.
Use in conditions
count_store('favorites') > 0Show a "Your Favorites" section only if the user has favorites.
Examples
Favorite toggle icon
`{ {in_store('favorites', row.id) ? 'heart-filled' : 'heart-outline'}}`Cart badge in navigation
Cart (`{ {count_store('cart')}}`)
// "Cart (3)"Conditional empty state
`{ {count_store('wishlist') == 0 ? 'Your wishlist is empty. Start browsing!' : ''}}`Combined check in a repeater
`{ {in_store('favorites', row.id) ? 'Remove from Favorites' : 'Add to Favorites'}}`TIP
For managing store contents in pipelines, use the Add to Store, Remove from Store, and Get Store Items nodes.