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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@kevisual/noco

v0.0.9

Published

一个轻量级的 NocoDB API SDK,支持表记录操作和 Base 管理功能。

Downloads

837

Readme

NocoDB API SDK

一个轻量级的 NocoDB API SDK,支持表记录操作和 Base 管理功能。

功能特性

  • 📋 记录操作: 完整的 CRUD 操作支持
  • 🗄️ Base 管理: 创建、列出、更新、删除 Bases
  • 🔗 关联数据: 支持链接字段操作
  • 📊 统计信息: 获取 Base 和记录统计
  • 🎯 类型安全: 完整的 TypeScript 类型定义

快速开始

基本用法

import { NocoApi } from '@kevisual/noco';

const nocoApi = new NocoApi({
  baseURL: 'https://your-nocodb-instance.com',
  token: 'your-api-token',
  table: 'your-table-name' // 可选,用于记录操作
});

// 记录操作
const listResult = await nocoApi.record.list();
await nocoApi.record.update({ Id: 1, Title: '更新的标题' });

Base 管理

// 列出所有 Bases
const bases = await nocoApi.meta.bases.list();
console.log('所有 Bases:', bases.list);

// 创建新的 Base
const newBase = await nocoApi.meta.bases.create({
  title: '我的新项目',
  description: '项目描述',
  color: '#ff6b35'
});

// 获取 Base 信息
const baseInfo = await nocoApi.meta.bases.get('base-id');

// 更新 Base
await nocoApi.meta.bases.update('base-id', {
  title: '更新的项目名',
  description: '更新的描述'
});

// 删除 Base
await nocoApi.meta.bases.delete('base-id');

高级功能

// 复制 Base
const duplicatedBase = await nocoApi.meta.bases.duplicate('base-id', {
  title: '复制的项目',
  description: '这是一个复制的项目'
});

// 获取 Base 统计信息
const stats = await nocoApi.meta.bases.getStats('base-id');

// 导入/导出 Base
await nocoApi.meta.bases.importBase(importData);
const exportData = await nocoApi.meta.bases.export('base-id');

API 参考

NocoApi 构造函数选项

type NocoApiOptions = {
  table?: string;     // 表名(用于记录操作)
  token?: string;     // API 令牌
  baseURL?: string;   // NocoDB 实例 URL
};

Base 操作类型

type BaseInfo = {
  id?: string;
  title: string;
  description?: string;
  config?: Record<string, any>;
  color?: string;
  meta?: Record<string, any>;
  order?: number;
  prefix?: string;
  status?: string;
  type?: string;
  created_at?: string;
  updated_at?: string;
};

type CreateBaseData = {
  title: string;
  description?: string;
  color?: string;
  meta?: Record<string, any>;
  config?: Record<string, any>;
};

记录操作

// 查询参数
type QueryParams = {
  fields?: string | string[];    // 选择字段
  sort?: string | string[];      // 排序
  where?: string;                // 查询条件
  offset?: number;               // 偏移量
  limit?: number;                // 限制数量
  viewId?: string;               // 视图 ID
};

// 列出记录
await nocoApi.record.list<T>(params);

// 创建记录
await nocoApi.record.create(data);

// 读取记录
await nocoApi.record.read(id);

// 更新记录
await nocoApi.record.update(data);

// 删除记录
await nocoApi.record.delete({ Id: id });

// 获取记录数量
await nocoApi.record.count();

链接字段操作

// 列出链接记录
await nocoApi.record.listLinks(linkFieldId, recordId);

// 更新链接
await nocoApi.record.updateLinks(linkFieldId, recordId, data);

// 删除链接
await nocoApi.record.deleteLinks(linkFieldId, recordId);

独立使用 Meta API

import { MetaBases } from '@kevisual/noco';

const metaBases = new MetaBases({
  token: 'your-api-token',
  baseURL: 'https://your-nocodb-instance.com'
});

const bases = await metaBases.list();

错误处理

try {
  const result = await nocoApi.meta.bases.create({
    title: '新项目'
  });
  
  if (result.code === 200) {
    console.log('创建成功:', result.data);
  } else {
    console.error('创建失败:', result.message);
  }
} catch (error) {
  console.error('请求错误:', error);
}

参考资料

Meta API

https://nocodb.com/apis/v2/meta

Data API

https://nocodb.com/apis/v2/data

许可证

MIT