K
Join ServerKysely
help
Extract OrderBy TS Keys
Hey I have the following query
And I'm trying to create a function that accepts that query and adds and orderBy expression based in some conditions
How can I get the accepted
const getBaseQuery = ({ offset, pageSize, slug }: GetBaseQuery) =>
db
.selectFrom((eb) =>
eb
.selectFrom(...)
.innerJoin(...)
.where(...)
.select([
...
])
.as(...)
)
.select([
...
])
.offset(offset)
.limit(pageSize);
And I'm trying to create a function that accepts that query and adds and orderBy expression based in some conditions
type BaseQuery = ReturnType<typeof getBaseQuery>;
type AddOrderBy = {
query: BaseQuery;
key?: 'what do I put here';
dir?: "asc" | "desc";
};
const addOrderBy = ({ query, key, dir }: AddOrderBy) => {
...
};
How can I get the accepted
key
value types so I can put them in my type
declaration?@Igal sorry for the ping 😅 I think this might had lost between other posts