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)
  )


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 ...
Was this page helpful?