King of the Short Bus
King of the Short Bus
DTDrizzle Team
Created by King of the Short Bus on 4/3/2024 in #help
findFirst returns array instead of entity - using aws-data-api/pg
The documentation for https://orm.drizzle.team/docs/rqb#find-many and https://orm.drizzle.team/docs/rqb#find-first also explicitly indicates that findFirst() should return a single entity, not an array
4 replies
DTDrizzle Team
Created by King of the Short Bus on 4/3/2024 in #help
findFirst returns array instead of entity - using aws-data-api/pg
@Sillvva Hmm, if that's the case, then the typing for findFirst() is incorrect. * The return type for findMany() is PgRelationalQuery<BuildQueryResult<TSchema, TFields, TConfig>[]> * The return type for findFirst() is PgRelationalQuery<BuildQueryResult<TSchema, TFields, TSelection> | undefined> See https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/query.ts#L34 and https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/query-builders/query.ts#L50 to confirm.
4 replies