1
0
Fork 0
mirror of synced 2024-08-18 19:41:30 +12:00

Reuse subjects

This commit is contained in:
Adria Navarro 2023-12-22 12:18:24 +01:00
parent bd221f2727
commit 5a45249ad4
2 changed files with 17 additions and 8 deletions

View file

@ -5,6 +5,7 @@ const {
createRow, createRow,
createTable, createTable,
getApp, getApp,
getRows,
} = require("./utils") } = require("./utils")
const Chance = require("chance") const Chance = require("chance")
@ -122,7 +123,9 @@ async function run() {
primaryDisplay: "Name", primaryDisplay: "Name",
}) })
const subjects = await batchCreate( const subjects = useExistingApp
? await getRows(apiKey, appId, subjectTable._id)
: await batchCreate(
apiKey, apiKey,
appId, appId,
subjectTable, subjectTable,

View file

@ -88,6 +88,12 @@ exports.createRow = async (apiKey, appId, table, body) => {
return (await res.json()).data return (await res.json()).data
} }
exports.getRows = async (apiKey, appId, tableId) => {
const url = `${URL_TABLE}/${tableId}/rows/search`
const res = await request(apiKey, url, "POST", {}, appId)
return (await res.json()).data
}
exports.createTable = async (apiKey, appId, config) => { exports.createTable = async (apiKey, appId, config) => {
const res = await request(apiKey, URL_TABLE, "POST", config, appId) const res = await request(apiKey, URL_TABLE, "POST", config, appId)
const json = await res.json() const json = await res.json()