Overview
Collection serves as a managed database service integrated directly into the Prisme.ai platform:Data Storage
Store structured data in document collections
Query Capabilities
Retrieve and filter data with powerful query options
Data Management
Create, update, and delete records with simple operations
Integration Ready
Seamlessly connect with automations and workflows
Key Features
Store flexible document structures:
- Schema-free Design: No rigid schema requirements
- Nested Data Support: Store complex, hierarchical data
- Data Types: Support for strings, numbers, booleans, arrays, objects, dates
- Automatic Indexing: Optimized for fast retrieval
- Document Size: Support for documents up to 16MB
How Collection Works
Collection provides a MongoDB-compatible interface integrated directly into the Prisme.ai platform:1
Collections Organization
Data is organized into collections, similar to tables in relational databases:
- Each collection contains related documents
- Collections are created automatically when used
- No schema definition is required
- Each workspace has its own collection namespace
2
Document Structure
Documents are stored as JSON-like objects:
- Each document has a unique
_id
field - Documents can have any structure
- Fields can contain various data types
- Nested objects and arrays are supported
- Documents in the same collection can have different structures
3
Data Operations
Operations are performed through simple, intuitive methods:
- Commands follow MongoDB syntax and patterns
- Results are returned in standard formats
- Operations are executed in a secure environment
- Performance is optimized for common use cases
4
Integration
Collection integrates with the rest of the Prisme.ai ecosystem:
- Direct usage in automations
- Connection to AI agents through tools
- Data exchange with other platform components
- Role-based access control
Basic Operations
Let’s explore the core operations you can perform with Collection:Inserting Data
Inserting Data
Add documents to a collection:The operation returns information about the inserted documents, including their assigned
_id
values.Finding Data
Finding Data
Retrieve documents from a collection:These operations allow you to retrieve documents with precise filtering and control over the results.
Updating Data
Updating Data
By default, updates use mongo But you can also use the MongoDB operators you want :These operations enable precise updates to documents, including field modifications, additions, and array operations.
$set
operator to only update given fields without removing other fields already existing in the matched record :Deleting Data
Deleting Data
Remove documents from a collection:These operations allow you to remove documents based on specific criteria.
Aggregation Operations
Aggregation Operations
Perform complex data analysis:Aggregation provides powerful data analysis capabilities, including grouping, filtering, and computation.
Find pagination
Find pagination
Pagination is enforced by returning only the first 50 matching entries by default. This number is configurable with options.limit.
You can then choose which page you are interested in using options.page, starting at 1 for the first page :Alternatively, you can use options.skip to finely select the matching page :
You can then choose which page you are interested in using options.page, starting at 1 for the first page :
Advanced Features
Collection includes several advanced features that enable sophisticated data management:Indexing
Create indexes to optimize query performance:
- Single-field indexes
- Compound indexes
- Text indexes for full-text search
- Unique indexes for constraint enforcement
Transactions
Ensure data consistency with multi-document transactions:
- Atomic operations across multiple documents
- Rollback on error
- Consistent reads within a transaction
- Isolation levels
Geospatial
Store and query location data:
- GeoJSON format support
- Proximity queries
- Geospatial indexing
- Area containment queries
Schema Validation
Optional schema validation for data consistency:
- JSON Schema validation
- Custom validation rules
- Validation actions (error or warning)
- Field restriction
Common Use Cases
Collection enables a wide range of use cases:User Management
Store and manage user information:
- User profiles
- Preferences
- Activity history
- Authentication data
Content Management
Manage structured content:
- Articles and posts
- Product information
- Media metadata
- Categorization and tagging
Workflow State
Track process and workflow state:
- Status tracking
- Approval flows
- Stage information
- Audit history
Data Collection
Collect and store form submissions:
- Survey responses
- Application data
- Contact requests
- Registration information
Integration with Prisme.ai Products
Collection works seamlessly with other Prisme.ai products:Enhance knowledge bases with Collection:
- Store metadata about knowledge base documents
- Track usage patterns and popular queries
- Maintain user feedback on responses
- Save and manage test results
Example: Contact Management System
Here’s an example of using Collection to build a contact management system:1
Define Data Structure
Plan your data organization:
- Contacts collection for individual contacts
- Companies collection for organization information
- Interactions collection for communication history
- Tags collection for categorization
2
Create Storage Operations
Implement data storage automations:
3
Implement Query Operations
Create data retrieval automations:
4
Create User Interface
Build a UI to interact with your data:
- Contact list view
- Contact detail view
- Add/edit contact forms
- Search and filtering
5
Implement Business Logic
Add specialized functionality:
- Duplicate detection
- Contact merging
- Import/export capabilities
- Notification system
Best Practices
Follow these recommendations to get the most from Collection:Data Modeling
Data Modeling
Design your data structure effectively:
- Use descriptive collection names
- Choose between embedding and referencing based on access patterns
- Keep document size reasonable (under 1MB when possible)
- Normalize data when it changes frequently
- Denormalize data to optimize common queries
- Use consistent field names across collections
Query Optimization
Query Optimization
Optimize your queries for better performance:
- Create indexes for frequently queried fields
- Write specific queries that use indexes
- Limit the number of documents returned
- Avoid complex regex patterns when possible
- Use aggregation for data processing, not application code
Data Validation
Data Validation
Ensure data quality and consistency:
- Validate input data before storage
- Consider using schema validation for critical collections
- Implement application-level validation for complex rules
- Use unique indexes to prevent duplicates
- Include creation and update timestamps
- Maintain audit trails for sensitive data
Security Considerations
Security Considerations
Protect your data with proper security practices:
- Apply proper access controls
- Validate input to prevent injection attacks
- Don’t store sensitive data without encryption
- Implement appropriate backup strategies
- Audit access to sensitive collections
- Follow the principle of least privilege
Limitations and Considerations
When using Collection, be aware of these considerations:- Document Size: Individual documents are limited to 16MB
- Nested Depth: Deep nesting of objects can impact performance
- Query Complexity: Very complex queries may have performance implications
- Transaction Limits: Transactions have time and size limitations
- Indexing Overhead: Indexes improve query performance but increase storage requirements and write overhead
- Consistency Model: Collection uses an eventually consistent model in some scenarios