Skip to main content
The collections module provides structured data storage and querying for automations. It supports both MongoDB and SQL backends, with automatic namespace isolation per workspace and app.
This module is meant to be used through the Collection application, which provides a ready-to-use UI for managing collections and schemas. The functions below are available directly via the run instruction for advanced use cases.

Schema Management

All collections automatically include createdAt, updatedAt, createdBy, and updatedBy fields.
Returns an array of collection names in the current workspace/app namespace.
Returns all schema definitions for the current namespace.
Returns usage statistics (document count, size, etc.).
Analyzes data and returns an inferred schema with warnings. Provide either collection or data.

Read Operations

Returns [entities, totalCount] — useful for paginated UIs.

Write Operations

createdAt and updatedAt are set automatically.

Update Operations

updatedAt is set automatically. Returns { modifiedCount, matchedCount }.
An empty query without allowMatchAll: true throws an error to prevent accidental mass updates.
Same parameters and behavior as updateOne, but affects all matching documents.
createdAt is set only on insert; updatedAt is always set.

Delete Operations

Returns { deletedCount }.
An empty query without allowMatchAll: true throws an error to prevent accidental mass deletion.
Same parameters as deleteOne, but deletes all matching documents.

Query Syntax

Queries use MongoDB-style operators:

Complete Example