how to pass array of ids as placeholder

hello there.... why this query works
await db.query.productTable.findMany({
where: (fields, o) =>
o.inArray(
fields.id,
featuredIds.map((ele) => +ele),
),
with: publicViewProductsWith,
orderBy: (fields, { desc }) => desc(fields.latestInventoryUpdateAt),
limit: 30,
});
await db.query.productTable.findMany({
where: (fields, o) =>
o.inArray(
fields.id,
featuredIds.map((ele) => +ele),
),
with: publicViewProductsWith,
orderBy: (fields, { desc }) => desc(fields.latestInventoryUpdateAt),
limit: 30,
});
but when i prepare and pass ids as placeholder, it throw syntax error near $10
export const featuredProductsPreparedQuery = db.query.productTable
.findMany({
where: (fields, o) =>
o.inArray(fields.id, sql.placeholder('ids')),
with: publicViewProductsWith,
orderBy: (fields, { desc }) =>
desc(fields.latestInventoryUpdateAt),
limit: 30,
})
.prepare('featured-products');
export const featuredProductsPreparedQuery = db.query.productTable
.findMany({
where: (fields, o) =>
o.inArray(fields.id, sql.placeholder('ids')),
with: publicViewProductsWith,
orderBy: (fields, { desc }) =>
desc(fields.latestInventoryUpdateAt),
limit: 30,
})
.prepare('featured-products');
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?