fredrikliljedahl
fredrikliljedahl
DTDrizzle Team
Created by fredrikliljedahl on 4/8/2025 in #help
Using values from an input
Hello! I'm trying to solve an issue I have with an endpoint I'm working on. I have to be able to provide values to override in the query, something like the mock-up code bellow. Is something like this possible?
const overridenValues = new Map<Id, Date>([[1, "2025-01-01"]])

const query = db
.select({
productId: products.id,
})
.from(products)
.where(
gte(
products.added,
sql`coalesce(${format(overridenValues.get(products.id), "yyyy-MM-dd")}, ${products.from})`
),
)
const overridenValues = new Map<Id, Date>([[1, "2025-01-01"]])

const query = db
.select({
productId: products.id,
})
.from(products)
.where(
gte(
products.added,
sql`coalesce(${format(overridenValues.get(products.id), "yyyy-MM-dd")}, ${products.from})`
),
)
1 replies