Datastore Command Guide
Learn how to use the data store slash command
Why Use a Data Store?
The data store provides a flexible way to organize and retrieve your data using a key + sort field system. Think of it like a smart filing cabinet where you can:
- Organize Related Data: Group similar items under the same key (like putting related files in the same folder)
- Find Specific Items: Quickly locate exact items using the sort field
- Scale Easily: Store multiple related items without creating complex folder structures
- Share Selectively: Control access to individual items or groups of items
- View Data Your Way: Display content as documents or tables based on your needs
Common Use Cases
- Store all meeting notes under key
meeting-notes
with dates as sort fields - Keep employee records under key
employees
with email addresses as sort fields - Track inventory across categories using category names as sort fields
- Manage project documentation with project codes as sort fields
- Use as a job queue
Basic Usage
The /datastore
command lets you create, read, update, and delete items in the data store. After typing /datastore
, you can specify your action and options in natural language.
Key and Sort Field Fundamentals
Important Rules
- The combination of
key
+sortField
must be unique - If you don’t specify a
sortField
, one will be automatically generated for you - You can have multiple items with the same
key
as long as they have differentsortField
values - Think of
key
as a folder name andsortField
as a unique identifier within that folder
Real-World Example
Imagine managing employee reviews:
This structure lets you:
- Keep all reviews under one key
- Find a specific employee’s review instantly
- Store multiple reviews for different employees
- Avoid duplicate reviews for the same employee
- Easily share specific reviews with managers
Key and Sort Field Patterns
-
Single Key Only (Auto-generated Sort Field)
- Sort field will be auto-generated
- Good for: Quick storage when uniqueness isn’t a concern
- Example: Daily notes where exact retrieval isn’t needed
-
Key + Date Sort Field
- Creates unique daily entries
- Good for: Time-series data, daily logs
- Example: Can’t have two items with key “meeting-notes” and sortField “2024-03-15”
-
Key + Email Sort Field
- One record per employee
- Good for: Per-user data
- Example: Can’t have duplicate reviews for the same email
-
Key + Category Sort Field
- Unique identifier within category
- Good for: Categorized items requiring unique IDs
-
Key + ID Sort Field
- Explicit unique identifiers
- Good for: Systems requiring specific IDs
Command Options
Creating Items
Basic syntax:
Available Options
Required Fields
key
: (Required) Primary identifier for your item. Think of it as a folder or category name.
Optional Fields
-
sortField
: Secondary identifier that makes the item unique when combined with key -
content
: The main content of your item -
metadata
: Custom attributes as a JSON objectFor tables:
-
logoUrl
: URL for a logo to display in the viewer -
permissions
: Array of view/edit permissions -
viewerType
: How the content should be displayed -
triggerUrls
: URLs to be called when the item changes
About Triggers
Datastore items can have triggers attached that fire when the item is updated. When you attach a trigger URL to an item:
- The trigger will be called any time the item changes (content, metadata, or any other field)
- Each URL in the triggerUrls object will be called with its corresponding API key
- The trigger receives information about what changed in the item
- You can update items without firing triggers using the “trigger off” option
Example of creating an item with a trigger:
To update an item without firing triggers, use:
Real-World Examples
- Project Documentation
- Sales Reports by Region
- Employee Training Records
- Product Inventory by Category
Managing Items
Reading Items
By key only (returns all items with that key):
By key and sort field (returns specific item):
Updating Items
Deleting Items
Best Practices
-
Keys
- Use plural nouns for collections (e.g., “projects”, “employees”)
- Keep them simple and descriptive
- Use consistent naming patterns
-
Sort Fields
- Use dates for time-based organization (YYYY-MM-DD)
- Use emails for per-user data
- Use IDs for unique records
- Use categories for grouping related items
-
Metadata
- Use for searchable attributes
- Keep structure consistent within similar items
- Avoid storing large amounts of data
-
Permissions
- Use view-only when possible
- Carefully consider who needs edit access
- Review shared links periodically
-
Triggers
- Use triggers for automation workflows
- Consider using “trigger off” for maintenance updates
- Keep track of your trigger URLs and API keys
- Test trigger endpoints before adding them to production items