# Working with Collections

All collections that have been setup for a component are available via the `rw.collections` object. Assuming we have a tags collection setup, you can do the following:

```javascript
const transformHook = (rw) => {
    const { tags } = rw.collections;

    // Example: Create an array of tag names
    const tagNames = tags.map(tag => tag.name);

    rw.setProps({
        tagNames
    });
}
exports.transformHook = transformHook;
```

If you want like to simple pass all the collections to the template, you can do so by spreading the `rw.collections` object into the `rw.setProps` method, like so

```javascript
const transformHook = (rw) => {
    rw.setProps({
        ...rw.collections
    });
}
exports.transformHook = transformHook;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.realmacsoftware.com/elements-docs/elements-language/component/hooks.js/working-with-collections.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
