Reuse subjects
This commit is contained in:
parent
bd221f2727
commit
5a45249ad4
2 changed files with 17 additions and 8 deletions
|
@ -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,14 +123,16 @@ async function run() {
|
||||||
primaryDisplay: "Name",
|
primaryDisplay: "Name",
|
||||||
})
|
})
|
||||||
|
|
||||||
const subjects = await batchCreate(
|
const subjects = useExistingApp
|
||||||
apiKey,
|
? await getRows(apiKey, appId, subjectTable._id)
|
||||||
appId,
|
: await batchCreate(
|
||||||
subjectTable,
|
apiKey,
|
||||||
Array.from({ length: SUBJECT_COUNT }).map(() => ({
|
appId,
|
||||||
Name: generator.profession(),
|
subjectTable,
|
||||||
}))
|
Array.from({ length: SUBJECT_COUNT }).map(() => ({
|
||||||
)
|
Name: generator.profession(),
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
|
||||||
const gradesTable = await upsertTable(appId, "Grades", {
|
const gradesTable = await upsertTable(appId, "Grades", {
|
||||||
schema: {
|
schema: {
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue