wemsamuel
wemsamuel
DTDrizzle Team
Created by wemsamuel on 9/4/2024 in #help
Use findMany or Select with Partial Types?
work around:
async findAll(data: Partial<DBCredit>): Promise<DBCredit[]> {
const conditions = Object.entries(data)
.filter(([_, value]) => value !== undefined)
.map(([key, value]) => eq(credits[key as keyof DBCredit], value as any));

const result = await this.db
.select()
.from(credits)
.where(and(...conditions));

return result;
}
async findAll(data: Partial<DBCredit>): Promise<DBCredit[]> {
const conditions = Object.entries(data)
.filter(([_, value]) => value !== undefined)
.map(([key, value]) => eq(credits[key as keyof DBCredit], value as any));

const result = await this.db
.select()
.from(credits)
.where(and(...conditions));

return result;
}
2 replies