rw.collections

The rw.collections object contains all collections defined for your component. Collections are arrays of structured data items that users can add, edit, and reorder.

Accessing Collections

const transformHook = (rw) => {
    const { tags, items, slides } = rw.collections;
    
    // Each collection is an array
    console.log(tags);   // [{ title: "Tag 1" }, { title: "Tag 2" }]
    console.log(items);  // [{ name: "Item 1", price: 10 }, ...]
};

exports.transformHook = transformHook;

Working with Collection Data

Mapping Collection Items

const transformHook = (rw) => {
    const { tags } = rw.collections;
    
    // Create a comma-separated list of tag names
    const tagList = tags.map(tag => tag.title).join(", ");
    
    rw.setProps({
        tagList
    });
};

exports.transformHook = transformHook;

Filtering Collections

Passing Collections to Templates

You can pass individual collections or spread all collections:

Or pass specific collections:

Using Collections in Templates

Once passed via setProps, collections can be iterated in templates:

Collection Item Properties

Each item in a collection has the properties defined in your collection schema. Common patterns include:

Last updated

Was this helpful?