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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@etsuyou/database

v1.0.5

Published

国内请求Seatable的API

Downloads

9

Readme

Seatable数据库使用手册

手册参考地址

地址替换

  • dtable-web:
    • https://cloud.seatable.cn/
  • dtable-server:
    • 一般是https://dtable-server-03.seatable.cn/等
  • dtable-db:
    • https://dtable-db.seatable.cn/

创建数据库

// 引入Database这个类
// CommonJS
const Database = require("@etsuyou/database");

// ES6
import Database from '@etsuyou/database'

// 对MyTest数据库进行可读可写操作的API_TOKEN
const API_TOKEN = '63c6b6ae343fc6c935cc8d0d29055eaf8b0645dd';
let database = new Database(API_TOKEN);

初始化数据库initSelf()

async function test(){
  // 使用其他方法之前必须先进行初始化
  await database.initSelf();
  
  // init后使用其他的方法
  // 要使用的方法
  // ...

}

test();

常用方法

async getTablesHeader()

获取数据库所有表的表头信息

// async getTablesHeader()
// 测试区开始
async function test(){
	// 使用其他方法之前必须先进行初始化
  await database.initSelf();

  // 从这里开始使用其他方法
  let arr = await database.getTablesHeader();
  console.dir(arr,{depth:null});

}

test();
// 测试区结束
[
  {
    tableName: 'Table1',
    columns: [
      { name: 'name', type: 'text' },    
      { name: 'password', type: 'text' },
      { name: 'test', type: 'text' }     
    ]
  }
]

image

async addOneRow(rowDataObj, table_name)

增加一行数据 rowDataObj:待增加数据,以对象形式传入 table_name:待插入字符串要加入表的表名,字符串类型

// async addOneRow(rowDataObj, table_name)
// 测试区开始
async function test(){
	// 使用其他方法之前必须先进行初始化
  await database.initSelf();

  // 从这里开始使用其他方法
  let rowDataObj ={
    name:"ceshi",
    password:"ceshi",
    test:"test"
  };
  let table_name = "Table1";
  let res_obj = await database.addOneRow(rowDataObj, table_name);
  console.log(res_obj);
}

test();
// 测试区结束
{
  rowID: 'A9shNhYqQJy8ELuN2I88Xw',
  createTime: '2024-03-09T07:20:40.902+00:00',
  modifyTime: '2024-03-09T07:20:40.902+00:00',
  obj: { name: 'ceshi', password: 'ceshi', test: 'test' }
}

image

async selectRows(sql)

通过SQL语句查询多行(一行)

// async selectRows(sql)
// 测试区开始
async function test(){
	// 使用其他方法之前必须先进行初始化
  await database.initSelf();

  // 从这里开始使用其他方法
  let sql = "select * from Table1 where name = 'ceshi' and password = 'ceshi';";
  let arr = await database.selectRows(sql)
  console.log(arr);
}

test();
// 测试区结束
{
  length: 2,
  arr: [
    {
      name: 'ceshi',
      password: 'ceshi',
      test: 'test',
      _locked: null,
      _locked_by: null,
      _archived: false,
      _creator: null,
      _ctime: '2024-03-09T15:20:40.903+08:00',
      _last_modifier: null,
      _mtime: '2024-03-09T15:20:40.903+08:00',
      _id: 'A9shNhYqQJy8ELuN2I88Xw'
    },
    {
      name: 'ceshi',
      password: 'ceshi',
      test: 'ceshi',
      _locked: null,
      _locked_by: null,
      _archived: false,
      _creator: '[email protected]',
      _ctime: '2024-03-09T15:23:04.088+08:00',
      _last_modifier: '[email protected]',
      _mtime: '2024-03-09T15:23:13.116+08:00',
      _id: 'LfyzpkjjSy6WrGEVoFhVTw'
    }
  ]
}

image

async updateOneRow(newRowDataObj, rowID, table_name)

更新表中一行数据 其中rowID可以通过上面selectRows方法获取

// async updateOneRow(newRowDataObj, rowID, table_name)
// 测试区开始
async function test(){
	// 使用其他方法之前必须先进行初始化
  await database.initSelf();

  // 从这里开始使用其他方法
  let newRowDataObj ={
    name:"ceshi_new",
    password:"ceshi_new",
    test:"ceshi_new"
  };
  let rowID = 'LfyzpkjjSy6WrGEVoFhVTw';
  let table_name = "Table1";
  let res = await database.updateOneRow(newRowDataObj, rowID, table_name);
  console.log(res);
}

test();
// 测试区结束
{ success: true }

image

async getTableAllRows(table_name)

获取表中所有的数据

// getTableAllRows(table_name)
// 测试区开始
async function test(){
	// 使用其他方法之前必须先进行初始化
  await database.initSelf();

  // 从这里开始使用其他方法
  let table_name = "Table1";
  let arr = await database.getTableAllRows(table_name);
  console.log(arr);
}

test();
// 测试区结束
[
  {
    _id: 'cSIwIoRbRsmHNyFoeiW8HA',
    _mtime: '2024-03-09T02:38:12.214+00:00',
    _ctime: '2024-03-09T02:37:50.046+00:00',
    name: 'zhangsan',
    password: '111'
  },
  {
    _id: 'GIPDuMwKQMKK55S_FQwDdw',
    _mtime: '2024-03-09T03:32:25.043+00:00',
    _ctime: '2024-03-09T02:37:50.046+00:00',
    name: 'lisi',
    password: '222',
    test: '444'
  },
  {
    _id: 'DoBx_PasSU-AFyB7NzoSlQ',
    _mtime: '2024-03-09T03:42:26.242+00:00',
    _ctime: '2024-03-09T03:32:08.899+00:00',
    name: 'lisi_new',
    password: '222_new',
    test: '555_new'
  },
  {
    _id: 'A9shNhYqQJy8ELuN2I88Xw',
    _mtime: '2024-03-09T07:20:40.903+00:00',
    _ctime: '2024-03-09T07:20:40.903+00:00',
    name: 'ceshi',
    password: 'ceshi',
    test: 'test'
  },
  {
    _id: 'LfyzpkjjSy6WrGEVoFhVTw',
    _mtime: '2024-03-09T07:32:53.921+00:00',
    _ctime: '2024-03-09T07:23:04.088+00:00',
    name: 'ceshi_new',
    password: 'ceshi_new',
    test: 'ceshi_new'
  }
]

image

async deleteOneRow(table_name, rowID)

删除一行数据

// 对MyTest数据库进行可读可写操作的API_TOKEN
const API_TOKEN = "63c6b6ae343fc6c935cc8d0d29055eaf8b0645dd";
let database = new Database(API_TOKEN);

// async deleteOneRow(table_name, rowID)
// 测试区开始
async function test() {
  // 使用其他方法之前必须先进行初始化
  await database.initSelf();

  // 从这里开始使用其他方法
  let table_name = "Table1";
  let arr = await database.getTableAllRows(table_name);
  console.log(arr);

  let to_delete_row_id = "O_P4clTOQpGC9OPrR8HJ-w";
  let res = await database.deleteOneRow(table_name, to_delete_row_id);
  console.log(res);
}

test();
// 测试区结束
{ deleted_rows: 1 }