bknd-crud-create
Use when inserting new records into a Bknd entity via the SDK or REST API. Covers createOne, createMany, creating with relations ($set), response handling, error handling, and common patterns for client-side record creation.
What this skill does
# CRUD Create
Insert new records into your Bknd database using the SDK or REST API.
## Prerequisites
- Bknd project running (local or deployed)
- Entity exists (use `bknd-create-entity` first)
- SDK configured or API endpoint known
## When to Use UI Mode
- Quick one-off data entry
- Manual testing during development
- Non-technical users adding records
**UI steps:** Admin Panel > Data > Select Entity > Click "+" or "Add" > Fill form > Save
## When to Use Code Mode
- Application logic for user-generated content
- Form submissions
- API integrations
- Automated record creation
## Code Approach
### Step 1: Set Up SDK Client
```typescript
import { Api } from "bknd";
const api = new Api({
host: "http://localhost:7654", // Your Bknd server
});
// If auth required:
api.updateToken("your-jwt-token");
```
### Step 2: Create Single Record
Use `createOne(entity, data)`:
```typescript
const { ok, data, error } = await api.data.createOne("posts", {
title: "My First Post",
content: "Hello world!",
published: false,
});
if (ok) {
console.log("Created post:", data.id);
} else {
console.error("Failed:", error.message);
}
```
### Step 3: Handle Response
The response object:
```typescript
type CreateResponse = {
ok: boolean; // Success/failure
data?: { // Created record (if ok)
id: number; // Auto-generated ID
// ...all fields with defaults applied
};
error?: { // Error info (if !ok)
message: string;
code: string;
};
};
```
### Step 4: Create with Relations
Link to existing related records using `$set`:
```typescript
// Link to single related record (many-to-one)
const { data } = await api.data.createOne("posts", {
title: "New Post",
author: { $set: 1 }, // Link to user with ID 1
});
// Link to multiple related records (many-to-many)
const { data } = await api.data.createOne("posts", {
title: "Tagged Post",
tags: { $set: [1, 2, 3] }, // Link to tag IDs 1, 2, 3
});
// Combine both
const { data } = await api.data.createOne("posts", {
title: "Complete Post",
content: "Full content here",
author: { $set: userId },
category: { $set: categoryId },
tags: { $set: [tagId1, tagId2] },
});
```
### Step 5: Create Multiple Records (Bulk)
Use `createMany(entity, data[])`:
```typescript
const { ok, data } = await api.data.createMany("tags", [
{ name: "javascript" },
{ name: "typescript" },
{ name: "bknd" },
]);
// data is array of created records
console.log("Created", data.length, "tags");
```
## REST API Approach
### Create One
```bash
curl -X POST http://localhost:7654/api/data/posts \
-H "Content-Type: application/json" \
-d '{"title": "New Post", "content": "Hello!"}'
```
### Create with Auth
```bash
curl -X POST http://localhost:7654/api/data/posts \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"title": "Protected Post"}'
```
### Create Many
```bash
curl -X POST http://localhost:7654/api/data/tags \
-H "Content-Type: application/json" \
-d '[{"name": "tag1"}, {"name": "tag2"}]'
```
### Create with Relations
```bash
curl -X POST http://localhost:7654/api/data/posts \
-H "Content-Type: application/json" \
-d '{"title": "Post", "author": {"$set": 1}}'
```
## React Integration
### Basic Form Submit
```tsx
import { useApp } from "bknd/react";
function CreatePostForm() {
const { api } = useApp();
const [title, setTitle] = useState("");
const [error, setError] = useState<string | null>(null);
const [loading, setLoading] = useState(false);
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
setLoading(true);
setError(null);
const { ok, data, error: apiError } = await api.data.createOne("posts", {
title,
published: false,
});
setLoading(false);
if (ok) {
console.log("Created:", data.id);
setTitle("");
} else {
setError(apiError.message);
}
}
return (
<form onSubmit={handleSubmit}>
<input
value={title}
onChange={(e) => setTitle(e.target.value)}
placeholder="Post title"
required
/>
<button type="submit" disabled={loading}>
{loading ? "Creating..." : "Create Post"}
</button>
{error && <p className="error">{error}</p>}
</form>
);
}
```
### With SWR Revalidation
```tsx
import { useApp } from "bknd/react";
import useSWR, { mutate } from "swr";
function PostsList() {
const { api } = useApp();
const { data: posts } = useSWR("posts", () =>
api.data.readMany("posts").then((r) => r.data)
);
async function createPost(title: string) {
const { ok, data } = await api.data.createOne("posts", { title });
if (ok) {
// Revalidate the posts list
mutate("posts");
}
return { ok, data };
}
return (
<div>
<CreateForm onCreate={createPost} />
<ul>
{posts?.map((post) => (
<li key={post.id}>{post.title}</li>
))}
</ul>
</div>
);
}
```
## Full Example
```typescript
import { Api } from "bknd";
const api = new Api({ host: "http://localhost:7654" });
// Authenticate first (if required)
await api.auth.login({ email: "[email protected]", password: "password" });
// Create a user
const { data: user } = await api.data.createOne("users", {
email: "[email protected]",
name: "New User",
role: "author",
});
// Create a post linked to user
const { data: post } = await api.data.createOne("posts", {
title: "My First Blog Post",
content: "This is the content of my post.",
published: true,
author: { $set: user.id },
});
// Create tags
const { data: tags } = await api.data.createMany("tags", [
{ name: "intro" },
{ name: "tutorial" },
]);
// Link tags to post (update after creation)
await api.data.updateOne("posts", post.id, {
tags: { $set: tags.map((t) => t.id) },
});
console.log("Created post:", post.id, "with tags:", tags.length);
```
## Field Default Handling
Bknd applies defaults for omitted fields:
```typescript
// Entity definition
entity("posts", {
title: text().required(),
status: text({ default_value: "draft" }),
view_count: number({ default_value: 0 }),
created_at: date({ default_value: "now" }),
});
// Create with minimal data
const { data } = await api.data.createOne("posts", {
title: "Just a title", // Only required field
});
// Result includes defaults
console.log(data);
// {
// id: 1,
// title: "Just a title",
// status: "draft", // default applied
// view_count: 0, // default applied
// created_at: "2025-01-20T..." // default applied
// }
```
## Validation Handling
Bknd validates data against schema:
```typescript
// Entity with constraints
entity("users", {
email: text().required().unique(),
name: text(),
});
// Missing required field
const { ok, error } = await api.data.createOne("users", {
name: "No Email",
});
// ok: false, error: { message: "email is required" }
// Duplicate unique field
const { ok, error } = await api.data.createOne("users", {
email: "[email protected]", // Already exists
});
// ok: false, error: { message: "UNIQUE constraint failed" }
```
## Common Patterns
### Create or Find Existing
```typescript
async function createOrFind(
api: Api,
entity: string,
data: object,
uniqueField: string
) {
// Try to find existing
const { data: existing } = await api.data.readOneBy(entity, {
where: { [uniqueField]: { $eq: data[uniqueField] } },
});
if (existing) {
return { created: false, data: existing };
}
// Create new
const { data: created } = await api.data.createOne(entity, data);
return { created: true, data: created };
}
// Usage
const { created, data } = await createOrFind(
api,
"users",
{ email: "[email protected]", name: "User" },
"email"
);
```
### Create with Optimistic UI
```typescript
function useCreatePost() {
const { api } = useApp();
const [posts, setPosts] = useState<PRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.