Drizzle TeamDT
Drizzle Team2y ago
13 replies
Vinny

Using sql.placeholder with limit in creating a prepared query

I am attempting to create a prepared query like this...

const findByNamePrepared = this.database
            .select()
            .from(table)
            .where(like(table.fullName, sql.placeholder('fullName')))
            .limit(sql.placeholder('limit'))
            .offset(sql.placeholder('offset'))
            .prepare();


It fails to compile with the following message:

error TS2345: Argument of type 'Placeholder<"limit", any>' is not assignable to parameter of type 'number'.
35             .limit(sql.placeholder('limit'))
error TS2345: Argument of type 'Placeholder<"offset", any>' is not assignable to parameter of type 'number'.
36             .offset(sql.placeholder('offset'))


How are placeholders suppose to work with limit and offset?
Was this page helpful?