Passing column values through custom TypeScript functions ...

I am attempting to do this:
const hz = db.$with('sq').as(
db
.select({
alt: sql<number>`cast(${
convertEquatorialToHorizontal(datetime, observer, {
ra: observations.ra,
dec: observations.dec
}).alt
} as float)`.as('alt')
})
.from(observations)
)
const hz = db.$with('sq').as(
db
.select({
alt: sql<number>`cast(${
convertEquatorialToHorizontal(datetime, observer, {
ra: observations.ra,
dec: observations.dec
}).alt
} as float)`.as('alt')
})
.from(observations)
)
Essentially, I want to pass through the Column values evaluated as numbers to a function which can calculate a value for every record in the database (altitude is essentially something that changes for any given Datetime, so it can not be stored on the table itself). I was wondering if anyone could advise on how this could be possibly done ... N.B. If it is of any use, I am using sqlite ...
1 Reply
Michael
MichaelOP6mo ago
Is there a way to essentially extract the { observations.ra, observations.dec } which are strings in the schema to a TypeScript number 🙏
Want results from more Discord servers?
Add your server