generated from template/apps-template
32 lines
809 B
TypeScript
32 lines
809 B
TypeScript
import { Life, NocoApi } from '../mod.ts';
|
|
import { generateMultipleRandomItems } from './random-data';
|
|
|
|
// const token = 'your'
|
|
// const baseId = 'your_base_id';
|
|
|
|
const token = 'CPrDfoajtCjayEYK17wOljE7R2E7DoTIw_7oUnjb'
|
|
const baseId = 'p1pderowf0zhugt'
|
|
let tableId = 'mierezd5z73kj26'
|
|
const nocoApi = new NocoApi({
|
|
baseURL: 'http://localhost:8080',
|
|
token
|
|
});
|
|
|
|
const life = new Life({ nocoApi, baseId });
|
|
|
|
// const tableRes = await life.createTable({
|
|
// title: '测试表格2',
|
|
// });
|
|
// tableId = tableRes.data?.id || '';
|
|
// console.log('tableId', tableId);
|
|
|
|
life.nocoApi.record.table = tableId;
|
|
const datas = generateMultipleRandomItems(1);
|
|
|
|
for (const data of datas) {
|
|
console.log('data', data);
|
|
const createRes = await life.nocoApi.record.create(data);
|
|
console.log('createRes', createRes);
|
|
}
|
|
|