-
Notifications
You must be signed in to change notification settings - Fork 300
Dynamic order by #174
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
Comments
For now you have to make do with multiple query versions or Once we get dynamic keyword / fragments support you will be able to do it like this: // Not working yet
sql`
select * from wat
orer by ${ sql(column) } ${ desc ? sql`desc` : sql`asc` }
` |
thanks for your fast reply :) |
this one is supported already right? i was looking for a way to use variables in columns. dynamic column names. the following surprisingly works, lol. await sql`
CREATE TABLE IF NOT EXISTS "users" (
"id" serial PRIMARY KEY,
"name" text NOT NULL,
"telegram_id" text,
"whatsapp_id" text,
"wechat_id" text,
UNIQUE("name")
);
`; const platform = 'telegram';
const platform_user_id = '123123123';
const users = await sql`
SELECT * FROM "users"
WHERE ${sql(platform.concat('_id'))} = ${platform_user_id}
LIMIT 1;
`; |
Oh yeah, that should be fine :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello, I am currently using a list protected by an enum to retrieve the order wanted by the request
I wonder if there was a way to use this list or if I need to create each case
example of list for order by
example of use case
The text was updated successfully, but these errors were encountered: