1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-09 08:45:55 +02:00
joplin/packages/lib/models/utils/paginationToSql.ts
2020-11-27 15:16:50 +00:00

16 lines
396 B
TypeScript

import { Pagination } from './types';
export default function(pagination: Pagination): string {
const sql: string[] = [];
for (let i = 0; i < pagination.order.length; i++) {
const o = pagination.order[i];
let item = `\`${o.by}\``;
if (!!o.caseInsensitive || !!pagination.caseInsensitive) item += ' COLLATE NOCASE';
item += ` ${o.dir}`;
sql.push(item);
}
return sql.join(', ');
}