bkend-data
Installation
SKILL.md
bkend.ai Data Management
Create tables, define schemas, and perform CRUD operations.
Actions
| Action | Description | Example |
|---|---|---|
table |
Create a new table | $bkend-data table users |
schema |
Design table schema | $bkend-data schema |
query |
Query data examples | $bkend-data query |
Creating Tables
Tables in bkend.ai are created through the dashboard or MCP:
Via Dashboard
- Go to project > Database
- Click "New Table"
- Define columns with types
Via MCP
Create a table called "posts" with:
- title (string, required)
- body (text, required)
- status (enum: draft/published, default: draft)
- author_id (reference to users)
- created_at (datetime, auto)
- updated_at (datetime, auto)
Column Types
| Type | Description | Example |
|---|---|---|
string |
Short text (max 255) | name, email, slug |
text |
Long text (unlimited) | body, description |
number |
Integer or float | age, price, count |
boolean |
True/false | is_active, is_published |
datetime |
Date and time | created_at, due_date |
enum |
Fixed set of values | status, role, type |
json |
JSON object | metadata, settings |
reference |
Foreign key to another table | author_id, category_id |
file |
File reference | avatar, attachment |
CRUD Operations
Create
const post = await bkend.data.create('posts', {
title: 'My First Post',
body: 'Hello world!',
status: 'draft',
author_id: currentUser.id,
});
Read (Single)
const post = await bkend.data.get('posts', postId);
Read (List with Filters)
const posts = await bkend.data.list('posts', {
status: 'published',
sort: '-created_at',
page: '1',
limit: '20',
});
Update
const updated = await bkend.data.update('posts', postId, {
title: 'Updated Title',
status: 'published',
});
Delete
await bkend.data.delete('posts', postId);
Query Patterns
Filtering
// Exact match
{ status: 'published' }
// Multiple filters (AND)
{ status: 'published', author_id: userId }
Sorting
// Ascending
{ sort: 'created_at' }
// Descending (prefix with -)
{ sort: '-created_at' }
Pagination
// Page-based
{ page: '2', limit: '10' }
Search
// Full-text search
{ search: 'keyword' }
React Hooks
// hooks/usePosts.ts
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
export function usePosts(filters?: Record<string, string>) {
return useQuery({
queryKey: ['posts', filters],
queryFn: () => bkend.data.list('posts', filters),
});
}
export function useCreatePost() {
const qc = useQueryClient();
return useMutation({
mutationFn: (data: CreatePostInput) => bkend.data.create('posts', data),
onSuccess: () => qc.invalidateQueries({ queryKey: ['posts'] }),
});
}
Schema Best Practices
- Always include
created_atandupdated_at - Use
referencetype for relationships - Add indexes on frequently filtered columns
- Use
enumfor fixed value sets - Use
jsonsparingly (harder to query)
Reference
See references/bkend-patterns.md for complete API client code and advanced patterns.
Related skills