AgentSkillsCN

bkend-data

bkend.ai数据管理指南。通过bkend.ai BaaS,掌握表、列、CRUD操作、模式设计、索引,以及查询过滤功能。 触发:bkend表、bkend列、bkend CRUD、bkend模式、bkend数据、 bkend表、bkend数据、CRUD、模式、bkend表、bkend数据、 bkend表、bkend数据、tabla bkend、donnees bkend、bkend-Daten、dati bkend 请勿用于:认证(请使用$bkend-auth)、文件存储(请使用$bkend-storage)。

SKILL.md
--- frontmatter
name: bkend-data
description: |
  bkend.ai data management guide. Tables, columns, CRUD operations,
  schema design, indexes, and query filtering with bkend.ai BaaS.
  Triggers: bkend table, bkend column, bkend CRUD, bkend schema, bkend data,
  bkend 테이블, bkend 데이터, CRUD, 스키마, bkendテーブル, bkendデータ,
  bkend表, bkend数据, tabla bkend, données bkend, bkend-Daten, dati bkend
  Do NOT use for: auth (use $bkend-auth), file storage (use $bkend-storage).

bkend.ai Data Management

Create tables, define schemas, and perform CRUD operations.

Actions

ActionDescriptionExample
tableCreate a new table$bkend-data table users
schemaDesign table schema$bkend-data schema
queryQuery data examples$bkend-data query

Creating Tables

Tables in bkend.ai are created through the dashboard or MCP:

Via Dashboard

  1. Go to project > Database
  2. Click "New Table"
  3. Define columns with types

Via MCP

code
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

TypeDescriptionExample
stringShort text (max 255)name, email, slug
textLong text (unlimited)body, description
numberInteger or floatage, price, count
booleanTrue/falseis_active, is_published
datetimeDate and timecreated_at, due_date
enumFixed set of valuesstatus, role, type
jsonJSON objectmetadata, settings
referenceForeign key to another tableauthor_id, category_id
fileFile referenceavatar, attachment

CRUD Operations

Create

typescript
const post = await bkend.data.create('posts', {
  title: 'My First Post',
  body: 'Hello world!',
  status: 'draft',
  author_id: currentUser.id,
});

Read (Single)

typescript
const post = await bkend.data.get('posts', postId);

Read (List with Filters)

typescript
const posts = await bkend.data.list('posts', {
  status: 'published',
  sort: '-created_at',
  page: '1',
  limit: '20',
});

Update

typescript
const updated = await bkend.data.update('posts', postId, {
  title: 'Updated Title',
  status: 'published',
});

Delete

typescript
await bkend.data.delete('posts', postId);

Query Patterns

Filtering

typescript
// Exact match
{ status: 'published' }

// Multiple filters (AND)
{ status: 'published', author_id: userId }

Sorting

typescript
// Ascending
{ sort: 'created_at' }

// Descending (prefix with -)
{ sort: '-created_at' }

Pagination

typescript
// Page-based
{ page: '2', limit: '10' }

Search

typescript
// Full-text search
{ search: 'keyword' }

React Hooks

typescript
// 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

  1. Always include created_at and updated_at
  2. Use reference type for relationships
  3. Add indexes on frequently filtered columns
  4. Use enum for fixed value sets
  5. Use json sparingly (harder to query)

Reference

See references/bkend-patterns.md for complete API client code and advanced patterns.