Skip to content

knex postgis #3299

Answered by daffl
ymarcon asked this question in Q&A
Oct 5, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You can still extend the createQuery or knexify methods and add your own functionality.

knexify(knexQuery: Knex.QueryBuilder, query: Query = {}, parentKey?: string): Knex.QueryBuilder {
  const q = super.knexify(knexQuery, query)

  return Object.keys(query).reduce((currentQuery, key) => {
    if (key === '$within') {
      const [lat, lon] = query[key]
      currentQuery.within(lat, lon)
    }
    return currentQuery
  })
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ymarcon
Comment options

Answer selected by ymarcon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants