mirror of
https://github.com/djdevin/recflare.git
synced 2026-10-25 23:18:51 -07:00
[apps] possible inventions fix
This commit is contained in:
@@ -1278,10 +1278,11 @@ export async function getInventionsByIds(
|
|||||||
inventionIds: number[]
|
inventionIds: number[]
|
||||||
): Promise<SavedInvention[]> {
|
): Promise<SavedInvention[]> {
|
||||||
if (inventionIds.length === 0) return []
|
if (inventionIds.length === 0) return []
|
||||||
const placeholders = inventionIds.map((_, i) => `?${i + 1}`).join(', ')
|
// One bound JSON array rather than a placeholder per id: D1 caps a statement at 100
|
||||||
|
// bound variables, and the top-today window or a big collection easily passes that.
|
||||||
const { results } = await db
|
const { results } = await db
|
||||||
.prepare(`SELECT data FROM invention WHERE id IN (${placeholders})`)
|
.prepare(`SELECT data FROM invention WHERE id IN (SELECT value FROM json_each(?1))`)
|
||||||
.bind(...inventionIds)
|
.bind(JSON.stringify(inventionIds))
|
||||||
.all<InventionRow>()
|
.all<InventionRow>()
|
||||||
|
|
||||||
const byId = new Map<number, SavedInvention>()
|
const byId = new Map<number, SavedInvention>()
|
||||||
|
|||||||
Reference in New Issue
Block a user