Return array when parsing a schema with drizzle-valibot

Hello guys, I just started using drizzle-valibot and I'm not able to find in their docs nor yours how to return an array when parsing a schema
// Schema
export const facturaciones = mysqlTable('...', {});
export type NuevaFacturacion = typeof facturaciones.$inferInsert;
export const nuevaFacturacionSchema = createInsertSchema(facturaciones);

// Controller
// Frontend can send many 'facturaciones', I want to parse each one of them
async guardar(@Body() facturaciones: NuevaFacturacion[]) {
// This doesn't return an array
const _facturaciones = parse(nuevaFacturacionSchema, facturaciones);
}
// Schema
export const facturaciones = mysqlTable('...', {});
export type NuevaFacturacion = typeof facturaciones.$inferInsert;
export const nuevaFacturacionSchema = createInsertSchema(facturaciones);

// Controller
// Frontend can send many 'facturaciones', I want to parse each one of them
async guardar(@Body() facturaciones: NuevaFacturacion[]) {
// This doesn't return an array
const _facturaciones = parse(nuevaFacturacionSchema, facturaciones);
}
Or do I have to iterate over the array and parse each item by myself?
Thanks in advance!
PS: I tried to add drizzle-valibot as a tag but it doesn't exist
1 Reply
ericmartinezr
ericmartinezrOP13mo ago
Answering myself
const _facturaciones = parse(array(nuevaFacturacionSchema), facturaciones);
const _facturaciones = parse(array(nuevaFacturacionSchema), facturaciones);
Sorry about the noise
Want results from more Discord servers?
Add your server