fix: custom info request returns array

This commit is contained in:
Rafael Taranto 2025-05-24 07:28:02 +01:00
parent b252333702
commit c7b1ff4c7d

View file

@ -1,7 +1,7 @@
import db from './db.js' import db from './db.js'
import { ExpressionBuilder } from 'kysely' import { ExpressionBuilder } from 'kysely'
import { Customers, DB, EditedCustomerData } from './types/types.js' import { Customers, DB, EditedCustomerData } from './types/types.js'
import { jsonObjectFrom } from 'kysely/helpers/postgres' import { jsonArrayFrom } from 'kysely/helpers/postgres'
type CustomerEB = ExpressionBuilder<DB & { c: Customers }, 'c'> type CustomerEB = ExpressionBuilder<DB & { c: Customers }, 'c'>
type CustomerWithEditedEB = ExpressionBuilder< type CustomerWithEditedEB = ExpressionBuilder<
@ -166,7 +166,7 @@ function getCustomerList(
]) ])
.$if(options.withCustomInfoRequest, qb => .$if(options.withCustomInfoRequest, qb =>
qb.select(({ eb, ref }) => qb.select(({ eb, ref }) =>
jsonObjectFrom( jsonArrayFrom(
eb eb
.selectFrom('customersCustomInfoRequests') .selectFrom('customersCustomInfoRequests')
.selectAll() .selectAll()