1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/packages/lib/models/utils/paginationToSql.ts

16 lines
396 B
TypeScript
Raw Normal View History

2020-11-05 18:58:23 +02:00
import { Pagination } from './types';
export default function(pagination: Pagination): string {
const sql: string[] = [];
2020-11-05 18:58:23 +02:00
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';
2020-11-05 18:58:23 +02:00
item += ` ${o.dir}`;
sql.push(item);
}
return sql.join(', ');
}