I'm stuck in EdgeDB query, one of my project's functionality is sort data by multiple columns. I would like to be able to specify any column, such as URL, createdDate, createdBy or any other column with different data types. Please check below code.
SELECT {
data := (
SELECT default::posts {
id,
url,
createdBy,
modifiedBy,
createdDate,
}
ORDER BY (
.url=(<optional str>$SortColumnName)??.url
)
)
)
}
I have tried this code but throwing this error
InvalidTypeError: operator '??' cannot be applied to operands of type 'std::str' and 'std::int16' Hint: Consider using an explicit type cast or a conversion function.
SELECT {
data := (
SELECT default::posts {
id,
url,
createdBy,
modifiedBy,
createdDate,
}
ORDER BY (
# .createdDate
.url=(<optional str>$SortColumnName)??.url ,
.noOfPosts=(<optional str>$SortColumnName)??.noOfPosts
)
)
}