`ts
const entities = [
["My first post", "my-first-post"],
["My second post", "my-second-post"],
];
await db.execute(sql`
WITH
"input" ("title", "slug") AS (
VALUES
${sql.join(entities, sql`, `)}
),
"new" AS (
INSERT INTO ${schema.entities} ("slug")
SELECT "slug"
FROM "input"
RETURNING "id", "slug"
)
INSERT INTO ${schema.posts} ("id", "title")
SELECT "new"."id", "input"."title"
FROM "new"
JOIN "input" USING ("slug");
`);
`ts
const entities = [
["My first post", "my-first-post"],
["My second post", "my-second-post"],
];
await db.execute(sql`
WITH
"input" ("title", "slug") AS (
VALUES
${sql.join(entities, sql`, `)}
),
"new" AS (
INSERT INTO ${schema.entities} ("slug")
SELECT "slug"
FROM "input"
RETURNING "id", "slug"
)
INSERT INTO ${schema.posts} ("id", "title")
SELECT "new"."id", "input"."title"
FROM "new"
JOIN "input" USING ("slug");
`);