npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@meituan-nocode/backend-sdk

v0.2.7

Published

NoCode Backend TypeScript SDK

Downloads

25

Readme

NoCode Entity SDK

NoCode 实体操作 SDK

安装

npm install @nocode/backend-sdk
# or
yarn add @nocode/backend-sdk

快速开始

基础配置

import { createClient } from '@nocode/backend-sdk';

// Create a client instance
export const nocodeBackend = createClient({
   appId: "your-app-id",
   serverUrl: "https://nocode.cn",
   env: 'test',
});

实体操作

// 获取Todo实体
export const Todo = nocodeBackend.entities.Todo;

// 获取所有Todo数据
await Todo.filter()

// 带条件筛选Todo数据
await Todo.filter({
  where: { priority: "极高", done: false },
  orderBy: "created_at",
  limit: 10,
  offset: 0
})

// 复杂排序条件
await Todo.filter({
  where: { priority: "极高" },
  orderBy: [
    { field: "priority", direction: "DESC" },
    { field: "created_at", direction: "ASC" }
  ],
  limit: 20
})

// 创建一条新Todo
await Todo.create({todo_content: "Todo 1", priority: "极高", "ddl": "1970-01-01 00:00:00"})

// 更新一条Todo数据
await Todo.update(1, {todo_content: "This is new content"})

// 删除一条Todo数据
await Todo.delete(1)

API 参考

实体操作

每个实体支持以下四种操作:

  • filter(conditions?) - 获取实体数据,支持筛选条件
  • create(data) - 创建新实体
  • update(id, data) - 更新指定ID的实体
  • delete(id) - 删除指定ID的实体

筛选条件 (FilterConditions)

filter 方法支持以下筛选条件,所有参数都是可选的:

interface FilterConditions {
  where?: Record<string, unknown>;    // 查询条件,支持字段名-值对
  orderBy?: string | Array<{          // 排序条件
    field: string;                    // 排序字段
    direction: 'ASC' | 'DESC';        // 排序方向
  }>;
  limit?: number;                     // 限制返回数量
  offset?: number;                    // 跳过前N条记录
}

使用示例:

1. 无条件查询 - 获取所有数据

await Todo.filter()

2. where 条件筛选 - 根据字段值过滤数据

// 单个条件:查找优先级为"极高"的Todo
await Todo.filter({ where: { priority: "极高" } })

// 多个条件:查找优先级为"极高"且pd为0的Todo
await Todo.filter({ where: { priority: "极高", pd: 0 } })

// 字符串匹配:查找已完成的任务 (pd=1)
await Todo.filter({ where: { pd: 1 } })

3. orderBy 排序 - 控制返回数据的排序方式

// 字符串格式:按创建时间降序排列
await Todo.filter({ orderBy: "created_at DESC" })

// 字符串格式:按截止时间升序排列
await Todo.filter({ orderBy: "ddl ASC" })

// 对象数组格式:多字段排序(先按优先级降序,再按创建时间升序)
await Todo.filter({
  orderBy: [
    { field: "priority", direction: "DESC" },
    { field: "created_at", direction: "ASC" }
  ]
})

4. limit 限制数量 - 控制返回记录的最大数量

// 只返回前3条记录
await Todo.filter({ limit: 3 })

// 结合where条件,只返回前2条优先级为"极高"的记录
await Todo.filter({
  where: { priority: "极高" },
  limit: 2
})

5. offset 分页偏移 - 跳过指定数量的记录

// 跳过前2条记录
await Todo.filter({ offset: 2 })

// 分页示例:获取第2页数据(每页2条)
await Todo.filter({ limit: 2, offset: 2 })  // 跳过前2条,取2条

// 分页示例:获取第1页数据
await Todo.filter({ limit: 2, offset: 0 })   // 从第1条开始,取2条

6. 组合条件 - 同时使用多个筛选参数

// 完整的筛选和分页示例
await Todo.filter({
  where: { priority: "极高", pd: 0 },     // 筛选条件:优先级极高且未完成
  orderBy: "created_at DESC",              // 排序:按创建时间降序
  limit: 2,                                // 限制:最多返回2条
  offset: 0                                // 偏移:从第1条开始
})

// 复杂排序的组合示例
await Todo.filter({
  where: { priority: "极高" },
  orderBy: [
    { field: "ddl", direction: "ASC" },        // 先按截止时间升序
    { field: "created_at", direction: "DESC" }  // 再按创建时间降序
  ],
  limit: 2,
  offset: 1
})

测试

本SDK提供了完整的测试套件,包括结构测试和功能测试。

Filter功能测试

npm run test:filter

⚠️ 注意:此测试需要真实的NoCode服务器连接

运行Filter测试前的配置

编辑 test/test_filter.mjs 文件,修改配置:

const nocodeBackend = createClient({
  appId: "your-real-app-id",           // 替换为真实的应用ID
  serverUrl: "https://your-server.com", // 替换为你的NoCode服务器地址
  env: 'test',
});

测试流程:

  1. 数据插入阶段:向数据库插入5条测试Todo数据
  2. Filter测试阶段:执行7种不同的筛选测试
    • 无条件查询 (await Todo.filter())
    • where条件筛选 ({ where: { priority: "极高" } })
    • 多条件筛选 ({ where: { priority: "极高", pd: 0 } })
    • orderBy排序 ({ orderBy: "created_at DESC" })
    • limit限制 ({ limit: 3 })
    • offset分页 ({ limit: 2, offset: 2 })
    • 组合条件 ({ where: {...}, orderBy: "...", limit: 2 })

License

MIT