"No Such Column" Error

I'm using TypeScript, DrizzleORM, and SQLite (better-sqlite-3)

export function searchTodosAndShares(listIDs: string[]) {
  if (listIDs.length === 0) return { shareMeta: [], todoMeta: [] }

  const shareStatementQuery = db
    .select({
      id: share.id,
      rowVersion: share.rowVersion,
      type: sql<string>`share`,
    })
    .from(share)
    .innerJoin(list, eq(share.listID, list.id))
    .where(inArray(list.id, listIDs))

  const todoStatementQuery = db
    .select({
      id: item.id,
      rowVersion: item.rowVersion,
      type: sql<string>`todo`,
    })
    .from(item)
    .where(inArray(list.id, listIDs))

  const sharesAndTodos = unionAll(
    shareStatementQuery,
    todoStatementQuery,
  )
    .prepare()
    .all()

  const result: {
    shareMeta: { id: string; rowVersion: number; }[],
    todoMeta: { id: string; rowVersion: number; }[] } = {
    shareMeta: [],
    todoMeta: [],
  }

  sharesAndTodos.forEach((row) => {
    const { id, rowVersion, type } = row
    result[type as 'shareMeta' | 'todoMeta'].push({ id, rowVersion })
  })

  return result
}


How come I get error of no such column: share or no such column: todo?

Thanks in advance for the help 🙂 🙏
Was this page helpful?