这是indexloc提供的服务,不要输入任何密码
Skip to content

etsuyou/SeaTable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Seatable数据库使用手册

手册参考地址

地址替换

💡 中文Seatable服务器地址变化

创建数据库

// 引入Database这个类
const Database = require("./Database.js");

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

初始化数据库initSelf()

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

}

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)

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

// 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: '048fe97ab93b44d1beea8e2634bbb039@auth.local',
      _ctime: '2024-03-09T15:23:04.088+08:00',
      _last_modifier: '048fe97ab93b44d1beea8e2634bbb039@auth.local',
      _mtime: '2024-03-09T15:23:13.116+08:00',
      _id: 'LfyzpkjjSy6WrGEVoFhVTw'
    }
  ]
}

image

async updateOneRow(newRowDataObj, rowID, table_name)

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published