Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
33 lines
902 B
Plaintext
33 lines
902 B
Plaintext
/**
|
|
* Takes the incoming sort argument and prefixes it with `versions.` and preserves any `-` prefixes for descending order
|
|
* @param sort
|
|
*/ export const getQueryDraftsSort = ({ collectionConfig, sort })=>{
|
|
if (!sort) {
|
|
if (collectionConfig.defaultSort) {
|
|
sort = collectionConfig.defaultSort;
|
|
} else {
|
|
sort = '-createdAt';
|
|
}
|
|
}
|
|
if (typeof sort === 'string') {
|
|
sort = [
|
|
sort
|
|
];
|
|
}
|
|
return sort.map((field)=>{
|
|
let orderBy;
|
|
let direction = '';
|
|
if (field[0] === '-') {
|
|
orderBy = field.substring(1);
|
|
direction = '-';
|
|
} else {
|
|
orderBy = field;
|
|
}
|
|
if (orderBy === 'id') {
|
|
return `${direction}parent`;
|
|
}
|
|
return `${direction}version.${orderBy}`;
|
|
});
|
|
};
|
|
|
|
//# sourceMappingURL=getQueryDraftsSort.js.map |