Dynamic Collection Manipulation Guide

:package: WeWeb Dynamic Collection Manipulation – Cheatsheet & Guide (June 28, 2025)

Hey everyone. :waving_hand: If you’ve ever felt limited by how collections behave in WeWeb, like needing to manually refresh data, dynamically update items, or programmatically apply filters, this guide could work for you.

These functions let you go beyond the default collection usage in workflows, using wwLib.wwCollection to fetch, update, or sync your collections with full control. You can use them inside JavaScript formula blocks, workflow logic, or custom event handlers tied to buttons, forms, tabs, or conditional flows.

:gear: How do you trigger these?

You can use these functions in:

  • JavaScript formula blocks (inside computed values or bindings)
  • Workflow logic blocks (e.g. on a button click, on mount, or after form submission)
  • Custom components (buttons, tabs, toggles, etc.)
  • Repeater items (e.g. add or remove items dynamically)
  • Custom input listeners or lifecycle events (e.g. onInputChange, onPageLoad, onRouteChange)

They’re super useful when WeWeb’s native logic blocks aren’t enough or too rigid for complex app behaviors.

NOTE: While these functions are part of WeWeb’s backend, they’re not officially documented or supported, which means they could stop working or change at any time.

Please feel free to correct me or add further detail if you find different functionality.

Best,
Bruno


Current Cheatsheet

Function Description Example in WeWeb JS Formula Block
fetchCollection(id) Re-fetch data from the collection return wwLib.wwCollection.fetchCollection('collection_id')
getCollection(id) Returns metadata/config info for the collection return wwLib.wwCollection.getCollection('collection_id')
getCollectionData(id) Returns actual data array of the collection return wwLib.wwCollection.getCollectionData('collection_id')
getCollectionPluginConfig(id) Get data source plugin config return wwLib.wwCollection.getCollectionPluginConfig('collection_id')
getCollectionQueryConfig(id) Get current filter/sort/query config return wwLib.wwCollection.getCollectionQueryConfig('collection_id')
getPaginationOptions(id) Get limit and offset settings return wwLib.wwCollection.getPaginationOptions('collection_id')
isCollection(id) Checks if the key is a valid collection (checks if the current object has a key “type” with values “single” and “collection”). return wwLib.wwCollection.isCollection('collection_id')
setOffset(id, offset) Set pagination offset return wwLib.wwCollection.setOffset('collection_id', 2)
syncCollection(id) Refresh view using filters/sort (no refetch) return wwLib.wwCollection.syncCollection('collection_id')
updateCollection(id, data, options) Insert, update, or delete items in a collection return wwLib.wwCollection.updateCollection('collection_id', new_object,{ updateType: "insert", updateIndex: 0 } );

:repeat_button: updateCollection() Extra Examples

Action Code
Insert item return wwLib.wwCollection.updateCollection('collection_id', { name: 'Bruno' }, { updateType: 'insert' })
Update item by ID return wwLib.wwCollection.updateCollection('collection_id', { name: 'Updated' }, { updateType: 'update', updateBy: 'id', idKey: 'id', idValue: 5 })
Delete item by index return wwLib.wwCollection.updateCollection('collection_id', null, { updateType: 'delete', updateIndex: 2 })
6 Likes

Awesome Bruno. this must have taken some time to create.

Thanks for sharing!

1 Like