Skip to content

Question: Named bindings #1654

@theoephraim

Description

@theoephraim

I have a situation where I have some pretty complex raw queries that are being constructed. To avoid dealing with escaping values myself, I'd like to let the query builder handle this. Additionally, because the queries are complex and constructed in many steps, I'd rather not have the ordering of the replacements be significant. In many other tools, I would use "named bindings" to do this, but I can't find any example of this in the docs.

For example, something like runQuery('SELECT * FROM mytable WHERE foo = :fooval', { fooval: 'value to use in the query' })

Knex mentions this here as "named bindings", but I can't seem to find the right way to get access to this method, as the TS type for queryBuilder.raw() only accepts a single string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions