-
Notifications
You must be signed in to change notification settings - Fork 568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to pass a query as parameter? #80
Comments
Just found out that there is using knex. Bookshelf.knex.raw(query).then(callback); |
@felipefac - that will create a raw query... can you give me a little more about the situation where you're looking to pass a query as a parameter? There might be a better way to do it. |
I was trying to pass a db function as a parameter like: The problem is the DATE(field) was going quoted to the database and i could not find a way to remove them. Then i tried model.query("where", Bookshelf.knex.raw("DATE(field)"I, "=", "2013-01-01").then ..... But the select ignored the last two parameters after the raw function was called and After some time i decided to use a raw SQL. I should have reported a issue yesterday. BTW great work on bookshelf congratulations. |
Try this: model.query("where", Bookshelf.knex.raw("DATE(field)"), "=", "2013-01-01")).then(... that way you're only defining the Also thanks! - glad you're enjoying it! |
I tried the method you described. The thing is the query returned was incomplete. 'Select * from table where Date(field)' and nothing else. |
Oh, that's right - it needs to be a full raw statement: model.query("where", Bookshelf.knex.raw("DATE(field) = ?"), "2013-01-01")) That's the syntax you'll want to use, and in that case you can dynamically pass a value like a |
No description provided.
The text was updated successfully, but these errors were encountered: