generated from template/apps-template
temp
This commit is contained in:
31
scripts/create.ts
Normal file
31
scripts/create.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user