Change tableid for source id

This commit is contained in:
Adria Navarro 2024-10-01 13:21:04 +02:00
parent 4b65ce4f8b
commit 97b70e1f5a
1 changed files with 80 additions and 81 deletions

View File

@ -64,7 +64,7 @@ describe.each([
let envCleanup: (() => void) | undefined let envCleanup: (() => void) | undefined
let datasource: Datasource | undefined let datasource: Datasource | undefined
let client: Knex | undefined let client: Knex | undefined
let table: Table let sourceId: string
let rows: Row[] let rows: Row[]
async function basicRelationshipTables(type: RelationshipType) { async function basicRelationshipTables(type: RelationshipType) {
@ -74,7 +74,7 @@ describe.each([
}, },
generator.guid().substring(0, 10) generator.guid().substring(0, 10)
) )
table = await createTable( sourceId = await createTable(
{ {
name: { name: "name", type: FieldType.STRING }, name: { name: "name", type: FieldType.STRING },
//@ts-ignore - API accepts this structure, will build out rest of definition //@ts-ignore - API accepts this structure, will build out rest of definition
@ -83,7 +83,7 @@ describe.each([
relationshipType: type, relationshipType: type,
name: "productCat", name: "productCat",
fieldName: "product", fieldName: "product",
tableId: relatedTable._id!, tableId: relatedTable,
constraints: { constraints: {
type: "array", type: "array",
}, },
@ -92,8 +92,7 @@ describe.each([
generator.guid().substring(0, 10) generator.guid().substring(0, 10)
) )
return { return {
relatedTable: await config.api.table.get(relatedTable._id!), relatedTable: await config.api.table.get(relatedTable),
table,
} }
} }
@ -137,17 +136,18 @@ describe.each([
}) })
async function createTable(schema: TableSchema, name?: string) { async function createTable(schema: TableSchema, name?: string) {
return await config.api.table.save( const table = await config.api.table.save(
tableForDatasource(datasource, { schema, name }) tableForDatasource(datasource, { schema, name })
) )
return table._id!
} }
async function createRows(arr: Record<string, any>[]) { async function createRows(arr: Record<string, any>[]) {
// Shuffling to avoid false positives given a fixed order // Shuffling to avoid false positives given a fixed order
await config.api.row.bulkImport(table._id!, { await config.api.row.bulkImport(sourceId, {
rows: _.shuffle(arr), rows: _.shuffle(arr),
}) })
rows = await config.api.row.fetch(table._id!) rows = await config.api.row.fetch(sourceId)
} }
class SearchAssertion { class SearchAssertion {
@ -332,7 +332,7 @@ describe.each([
} }
function expectSearch(query: Omit<RowSearchParams, "tableId">) { function expectSearch(query: Omit<RowSearchParams, "tableId">) {
return new SearchAssertion({ ...query, tableId: table._id! }) return new SearchAssertion({ ...query, tableId: sourceId })
} }
function expectQuery(query: SearchFilters) { function expectQuery(query: SearchFilters) {
@ -341,7 +341,7 @@ describe.each([
describe("boolean", () => { describe("boolean", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
isTrue: { name: "isTrue", type: FieldType.BOOLEAN }, isTrue: { name: "isTrue", type: FieldType.BOOLEAN },
}) })
await createRows([{ isTrue: true }, { isTrue: false }]) await createRows([{ isTrue: true }, { isTrue: false }])
@ -482,7 +482,7 @@ describe.each([
}) })
) )
table = await createTable({ sourceId = await createTable({
name: { name: "name", type: FieldType.STRING }, name: { name: "name", type: FieldType.STRING },
appointment: { name: "appointment", type: FieldType.DATETIME }, appointment: { name: "appointment", type: FieldType.DATETIME },
single_user: { single_user: {
@ -764,7 +764,7 @@ describe.each([
describe.each([FieldType.STRING, FieldType.LONGFORM])("%s", () => { describe.each([FieldType.STRING, FieldType.LONGFORM])("%s", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
name: { name: "name", type: FieldType.STRING }, name: { name: "name", type: FieldType.STRING },
}) })
await createRows([{ name: "foo" }, { name: "bar" }]) await createRows([{ name: "foo" }, { name: "bar" }])
@ -1055,7 +1055,7 @@ describe.each([
datasourceId: datasource!._id!, datasourceId: datasource!._id!,
}) })
table = resp.datasource.entities![tableName] sourceId = resp.datasource.entities![tableName]._id!
await createRows([{ name: "foo" }, { name: "bar" }]) await createRows([{ name: "foo" }, { name: "bar" }])
}) })
@ -1079,7 +1079,7 @@ describe.each([
describe("numbers", () => { describe("numbers", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
age: { name: "age", type: FieldType.NUMBER }, age: { name: "age", type: FieldType.NUMBER },
}) })
await createRows([{ age: 1 }, { age: 10 }]) await createRows([{ age: 1 }, { age: 10 }])
@ -1252,7 +1252,7 @@ describe.each([
const JAN_10TH = "2020-01-10T00:00:00.000Z" const JAN_10TH = "2020-01-10T00:00:00.000Z"
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
dob: { name: "dob", type: FieldType.DATETIME }, dob: { name: "dob", type: FieldType.DATETIME },
}) })
@ -1399,7 +1399,7 @@ describe.each([
const NULL_TIME__ID = `null_time__id` const NULL_TIME__ID = `null_time__id`
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
timeid: { name: "timeid", type: FieldType.STRING }, timeid: { name: "timeid", type: FieldType.STRING },
time: { name: "time", type: FieldType.DATETIME, timeOnly: true }, time: { name: "time", type: FieldType.DATETIME, timeOnly: true },
}) })
@ -1560,7 +1560,7 @@ describe.each([
describe.each([FieldType.ARRAY, FieldType.OPTIONS])("%s", () => { describe.each([FieldType.ARRAY, FieldType.OPTIONS])("%s", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
numbers: { numbers: {
name: "numbers", name: "numbers",
type: FieldType.ARRAY, type: FieldType.ARRAY,
@ -1657,7 +1657,7 @@ describe.each([
let BIG = "9223372036854775807" let BIG = "9223372036854775807"
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
num: { name: "num", type: FieldType.BIGINT }, num: { name: "num", type: FieldType.BIGINT },
}) })
await createRows([{ num: SMALL }, { num: MEDIUM }, { num: BIG }]) await createRows([{ num: SMALL }, { num: MEDIUM }, { num: BIG }])
@ -1762,7 +1762,7 @@ describe.each([
isInternal && isInternal &&
describe("auto", () => { describe("auto", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
auto: { auto: {
name: "auto", name: "auto",
type: FieldType.AUTO, type: FieldType.AUTO,
@ -1912,21 +1912,18 @@ describe.each([
// be stable or pagination will break. We don't want the user to need // be stable or pagination will break. We don't want the user to need
// to specify an order for pagination to work. // to specify an order for pagination to work.
it("is stable without a sort specified", async () => { it("is stable without a sort specified", async () => {
let { rows: fullRowList } = await config.api.row.search( let { rows: fullRowList } = await config.api.row.search(sourceId, {
table._id!, tableId: sourceId,
{ query: {},
tableId: table._id!, })
query: {},
}
)
// repeat the search many times to check the first row is always the same // repeat the search many times to check the first row is always the same
let bookmark: string | number | undefined, let bookmark: string | number | undefined,
hasNextPage: boolean | undefined = true, hasNextPage: boolean | undefined = true,
rowCount: number = 0 rowCount: number = 0
do { do {
const response = await config.api.row.search(table._id!, { const response = await config.api.row.search(sourceId, {
tableId: table._id!, tableId: sourceId,
limit: 1, limit: 1,
paginate: true, paginate: true,
query: {}, query: {},
@ -1949,8 +1946,8 @@ describe.each([
// eslint-disable-next-line no-constant-condition // eslint-disable-next-line no-constant-condition
while (true) { while (true) {
const response = await config.api.row.search(table._id!, { const response = await config.api.row.search(sourceId, {
tableId: table._id!, tableId: sourceId,
limit: 3, limit: 3,
query: {}, query: {},
bookmark, bookmark,
@ -1973,7 +1970,7 @@ describe.each([
describe("field name 1:name", () => { describe("field name 1:name", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
"1:name": { name: "1:name", type: FieldType.STRING }, "1:name": { name: "1:name", type: FieldType.STRING },
}) })
await createRows([{ "1:name": "bar" }, { "1:name": "foo" }]) await createRows([{ "1:name": "bar" }, { "1:name": "foo" }])
@ -2007,14 +2004,14 @@ describe.each([
}, },
"array" "array"
) )
table = await createTable( sourceId = await createTable(
{ {
relationship: { relationship: {
type: FieldType.LINK, type: FieldType.LINK,
relationshipType: RelationshipType.MANY_TO_ONE, relationshipType: RelationshipType.MANY_TO_ONE,
name: "relationship", name: "relationship",
fieldName: "relate", fieldName: "relate",
tableId: arrayTable._id!, tableId: arrayTable,
constraints: { constraints: {
type: "array", type: "array",
}, },
@ -2030,17 +2027,17 @@ describe.each([
"main" "main"
) )
const arrayRows = await Promise.all([ const arrayRows = await Promise.all([
config.api.row.save(arrayTable._id!, { config.api.row.save(arrayTable, {
name: "foo", name: "foo",
array: ["option 1"], array: ["option 1"],
}), }),
config.api.row.save(arrayTable._id!, { config.api.row.save(arrayTable, {
name: "bar", name: "bar",
array: ["option 2"], array: ["option 2"],
}), }),
]) ])
await Promise.all([ await Promise.all([
config.api.row.save(table._id!, { config.api.row.save(sourceId, {
relationship: [arrayRows[0]._id, arrayRows[1]._id], relationship: [arrayRows[0]._id, arrayRows[1]._id],
}), }),
]) ])
@ -2059,7 +2056,7 @@ describe.each([
user1 = await config.createUser({ _id: `us_${utils.newid()}` }) user1 = await config.createUser({ _id: `us_${utils.newid()}` })
user2 = await config.createUser({ _id: `us_${utils.newid()}` }) user2 = await config.createUser({ _id: `us_${utils.newid()}` })
table = await createTable({ sourceId = await createTable({
user: { user: {
name: "user", name: "user",
type: FieldType.BB_REFERENCE_SINGLE, type: FieldType.BB_REFERENCE_SINGLE,
@ -2139,7 +2136,7 @@ describe.each([
user1 = await config.createUser({ _id: `us_${utils.newid()}` }) user1 = await config.createUser({ _id: `us_${utils.newid()}` })
user2 = await config.createUser({ _id: `us_${utils.newid()}` }) user2 = await config.createUser({ _id: `us_${utils.newid()}` })
table = await createTable({ sourceId = await createTable({
users: { users: {
name: "users", name: "users",
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
@ -2260,15 +2257,15 @@ describe.each([
]) ])
await Promise.all([ await Promise.all([
config.api.row.save(table._id!, { config.api.row.save(sourceId, {
name: "foo", name: "foo",
productCat: [productCatRows[0]._id], productCat: [productCatRows[0]._id],
}), }),
config.api.row.save(table._id!, { config.api.row.save(sourceId, {
name: "bar", name: "bar",
productCat: [productCatRows[1]._id], productCat: [productCatRows[1]._id],
}), }),
config.api.row.save(table._id!, { config.api.row.save(sourceId, {
name: "baz", name: "baz",
productCat: [], productCat: [],
}), }),
@ -2304,7 +2301,7 @@ describe.each([
const { relatedTable } = await basicRelationshipTables( const { relatedTable } = await basicRelationshipTables(
RelationshipType.MANY_TO_ONE RelationshipType.MANY_TO_ONE
) )
const mainRow = await config.api.row.save(table._id!, { const mainRow = await config.api.row.save(sourceId, {
name: "foo", name: "foo",
}) })
for (let i = 0; i < 11; i++) { for (let i = 0; i < 11; i++) {
@ -2329,7 +2326,7 @@ describe.each([
}) })
;(isSqs || isLucene) && ;(isSqs || isLucene) &&
describe("relations to same table", () => { describe("relations to same table", () => {
let relatedTable: Table, relatedRows: Row[] let relatedTable: string, relatedRows: Row[]
beforeAll(async () => { beforeAll(async () => {
relatedTable = await createTable( relatedTable = await createTable(
@ -2338,36 +2335,36 @@ describe.each([
}, },
"productCategory" "productCategory"
) )
table = await createTable({ sourceId = await createTable({
name: { name: "name", type: FieldType.STRING }, name: { name: "name", type: FieldType.STRING },
related1: { related1: {
type: FieldType.LINK, type: FieldType.LINK,
name: "related1", name: "related1",
fieldName: "main1", fieldName: "main1",
tableId: relatedTable._id!, tableId: relatedTable,
relationshipType: RelationshipType.MANY_TO_MANY, relationshipType: RelationshipType.MANY_TO_MANY,
}, },
related2: { related2: {
type: FieldType.LINK, type: FieldType.LINK,
name: "related2", name: "related2",
fieldName: "main2", fieldName: "main2",
tableId: relatedTable._id!, tableId: relatedTable,
relationshipType: RelationshipType.MANY_TO_MANY, relationshipType: RelationshipType.MANY_TO_MANY,
}, },
}) })
relatedRows = await Promise.all([ relatedRows = await Promise.all([
config.api.row.save(relatedTable._id!, { name: "foo" }), config.api.row.save(relatedTable, { name: "foo" }),
config.api.row.save(relatedTable._id!, { name: "bar" }), config.api.row.save(relatedTable, { name: "bar" }),
config.api.row.save(relatedTable._id!, { name: "baz" }), config.api.row.save(relatedTable, { name: "baz" }),
config.api.row.save(relatedTable._id!, { name: "boo" }), config.api.row.save(relatedTable, { name: "boo" }),
]) ])
await Promise.all([ await Promise.all([
config.api.row.save(table._id!, { config.api.row.save(sourceId, {
name: "test", name: "test",
related1: [relatedRows[0]._id!], related1: [relatedRows[0]._id!],
related2: [relatedRows[1]._id!], related2: [relatedRows[1]._id!],
}), }),
config.api.row.save(table._id!, { config.api.row.save(sourceId, {
name: "test2", name: "test2",
related1: [relatedRows[2]._id!], related1: [relatedRows[2]._id!],
related2: [relatedRows[3]._id!], related2: [relatedRows[3]._id!],
@ -2430,7 +2427,7 @@ describe.each([
isInternal && isInternal &&
describe("no column error backwards compat", () => { describe("no column error backwards compat", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
name: { name: {
name: "name", name: "name",
type: FieldType.STRING, type: FieldType.STRING,
@ -2453,7 +2450,7 @@ describe.each([
!isLucene && !isLucene &&
describe("row counting", () => { describe("row counting", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
name: { name: {
name: "name", name: "name",
type: FieldType.STRING, type: FieldType.STRING,
@ -2488,7 +2485,7 @@ describe.each([
describe("Invalid column definitions", () => { describe("Invalid column definitions", () => {
beforeAll(async () => { beforeAll(async () => {
// need to create an invalid table - means ignoring typescript // need to create an invalid table - means ignoring typescript
table = await createTable({ sourceId = await createTable({
// @ts-ignore // @ts-ignore
invalid: { invalid: {
type: FieldType.STRING, type: FieldType.STRING,
@ -2518,7 +2515,7 @@ describe.each([
"special (%s) case", "special (%s) case",
column => { column => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
[column]: { [column]: {
name: column, name: column,
type: FieldType.STRING, type: FieldType.STRING,
@ -2543,8 +2540,8 @@ describe.each([
describe("sample data", () => { describe("sample data", () => {
beforeAll(async () => { beforeAll(async () => {
await config.api.application.addSampleData(config.appId!) await config.api.application.addSampleData(config.appId!)
table = DEFAULT_EMPLOYEE_TABLE_SCHEMA sourceId = DEFAULT_EMPLOYEE_TABLE_SCHEMA._id!
rows = await config.api.row.fetch(table._id!) rows = await config.api.row.fetch(sourceId)
}) })
it("should be able to search sample data", async () => { it("should be able to search sample data", async () => {
@ -2567,7 +2564,7 @@ describe.each([
const earlyDate = "2024-07-03T10:00:00.000Z", const earlyDate = "2024-07-03T10:00:00.000Z",
laterDate = "2024-07-03T11:00:00.000Z" laterDate = "2024-07-03T11:00:00.000Z"
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
date: { date: {
name: "date", name: "date",
type: FieldType.DATETIME, type: FieldType.DATETIME,
@ -2610,7 +2607,7 @@ describe.each([
"ชื่อผู้ใช้", // Thai for "username" "ชื่อผู้ใช้", // Thai for "username"
])("non-ascii column name: %s", name => { ])("non-ascii column name: %s", name => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
[name]: { [name]: {
name, name,
type: FieldType.STRING, type: FieldType.STRING,
@ -2637,7 +2634,7 @@ describe.each([
isInternal && isInternal &&
describe("space at end of column name", () => { describe("space at end of column name", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
"name ": { "name ": {
name: "name ", name: "name ",
type: FieldType.STRING, type: FieldType.STRING,
@ -2672,7 +2669,7 @@ describe.each([
;(isSqs || isInMemory) && ;(isSqs || isInMemory) &&
describe("space at start of column name", () => { describe("space at start of column name", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
" name": { " name": {
name: " name", name: " name",
type: FieldType.STRING, type: FieldType.STRING,
@ -2705,7 +2702,7 @@ describe.each([
isSqs && isSqs &&
describe("duplicate columns", () => { describe("duplicate columns", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
name: { name: {
name: "name", name: "name",
type: FieldType.STRING, type: FieldType.STRING,
@ -2713,7 +2710,7 @@ describe.each([
}) })
await context.doInAppContext(config.getAppId(), async () => { await context.doInAppContext(config.getAppId(), async () => {
const db = context.getAppDB() const db = context.getAppDB()
const tableDoc = await db.get<Table>(table._id!) const tableDoc = await db.get<Table>(sourceId)
tableDoc.schema.Name = { tableDoc.schema.Name = {
name: "Name", name: "Name",
type: FieldType.STRING, type: FieldType.STRING,
@ -2747,7 +2744,7 @@ describe.each([
type: FieldType.STRING, type: FieldType.STRING,
}, },
}) })
table = await createTable({ sourceId = await createTable({
name: { name: {
name: "name", name: "name",
type: FieldType.STRING, type: FieldType.STRING,
@ -2756,15 +2753,15 @@ describe.each([
name: "rel", name: "rel",
type: FieldType.LINK, type: FieldType.LINK,
relationshipType: RelationshipType.MANY_TO_MANY, relationshipType: RelationshipType.MANY_TO_MANY,
tableId: toRelateTable._id!, tableId: toRelateTable,
fieldName: "rel", fieldName: "rel",
}, },
}) })
const [row1, row2] = await Promise.all([ const [row1, row2] = await Promise.all([
config.api.row.save(toRelateTable._id!, { name: "tag 1" }), config.api.row.save(toRelateTable, { name: "tag 1" }),
config.api.row.save(toRelateTable._id!, { name: "tag 2" }), config.api.row.save(toRelateTable, { name: "tag 2" }),
]) ])
row = await config.api.row.save(table._id!, { row = await config.api.row.save(sourceId, {
name: "product 1", name: "product 1",
rel: [row1._id, row2._id], rel: [row1._id, row2._id],
}) })
@ -2783,7 +2780,7 @@ describe.each([
!isInternal && !isInternal &&
describe("search by composite key", () => { describe("search by composite key", () => {
beforeAll(async () => { beforeAll(async () => {
table = await config.api.table.save( const table = await config.api.table.save(
tableForDatasource(datasource, { tableForDatasource(datasource, {
schema: { schema: {
idColumn1: { idColumn1: {
@ -2798,6 +2795,7 @@ describe.each([
primary: ["idColumn1", "idColumn2"], primary: ["idColumn1", "idColumn2"],
}) })
) )
sourceId = table._id!
await createRows([{ idColumn1: 1, idColumn2: 2 }]) await createRows([{ idColumn1: 1, idColumn2: 2 }])
}) })
@ -2819,13 +2817,13 @@ describe.each([
isSql && isSql &&
describe("primaryDisplay", () => { describe("primaryDisplay", () => {
beforeAll(async () => { beforeAll(async () => {
let toRelateTable = await createTable({ let toRelateTableId = await createTable({
name: { name: {
name: "name", name: "name",
type: FieldType.STRING, type: FieldType.STRING,
}, },
}) })
table = await config.api.table.save( const table = await config.api.table.save(
tableForDatasource(datasource, { tableForDatasource(datasource, {
schema: { schema: {
name: { name: {
@ -2836,13 +2834,14 @@ describe.each([
name: "link", name: "link",
type: FieldType.LINK, type: FieldType.LINK,
relationshipType: RelationshipType.MANY_TO_ONE, relationshipType: RelationshipType.MANY_TO_ONE,
tableId: toRelateTable._id!, tableId: toRelateTableId,
fieldName: "link", fieldName: "link",
}, },
}, },
}) })
) )
toRelateTable = await config.api.table.get(toRelateTable._id!) sourceId = table._id!
const toRelateTable = await config.api.table.get(toRelateTableId)
await config.api.table.save({ await config.api.table.save({
...toRelateTable, ...toRelateTable,
primaryDisplay: "link", primaryDisplay: "link",
@ -2851,7 +2850,7 @@ describe.each([
config.api.row.save(toRelateTable._id!, { name: "test" }), config.api.row.save(toRelateTable._id!, { name: "test" }),
]) ])
await Promise.all([ await Promise.all([
config.api.row.save(table._id!, { config.api.row.save(sourceId, {
name: "test", name: "test",
link: relatedRows.map(row => row._id), link: relatedRows.map(row => row._id),
}), }),
@ -2870,7 +2869,7 @@ describe.each([
!isLucene && !isLucene &&
describe("$and", () => { describe("$and", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
age: { name: "age", type: FieldType.NUMBER }, age: { name: "age", type: FieldType.NUMBER },
name: { name: "name", type: FieldType.STRING }, name: { name: "name", type: FieldType.STRING },
}) })
@ -2999,7 +2998,7 @@ describe.each([
!isLucene && !isLucene &&
describe("$or", () => { describe("$or", () => {
beforeAll(async () => { beforeAll(async () => {
table = await createTable({ sourceId = await createTable({
age: { name: "age", type: FieldType.NUMBER }, age: { name: "age", type: FieldType.NUMBER },
name: { name: "name", type: FieldType.STRING }, name: { name: "name", type: FieldType.STRING },
}) })
@ -3159,20 +3158,20 @@ describe.each([
row[name] = i row[name] = i
} }
const relatedTable = await createTable(relatedSchema) const relatedTable = await createTable(relatedSchema)
table = await createTable({ sourceId = await createTable({
name: { name: "name", type: FieldType.STRING }, name: { name: "name", type: FieldType.STRING },
related1: { related1: {
type: FieldType.LINK, type: FieldType.LINK,
name: "related1", name: "related1",
fieldName: "main1", fieldName: "main1",
tableId: relatedTable._id!, tableId: relatedTable,
relationshipType: RelationshipType.MANY_TO_MANY, relationshipType: RelationshipType.MANY_TO_MANY,
}, },
}) })
relatedRows = await Promise.all([ relatedRows = await Promise.all([
config.api.row.save(relatedTable._id!, row), config.api.row.save(relatedTable, row),
]) ])
await config.api.row.save(table._id!, { await config.api.row.save(sourceId, {
name: "foo", name: "foo",
related1: [relatedRows[0]._id], related1: [relatedRows[0]._id],
}) })