join-monster
Version:
A GraphQL to SQL query execution layer for batch data fetching.
31 lines (30 loc) • 871 B
JavaScript
;
var _shared = require("../shared");
function quote(str) {
return `"${str}"`;
}
module.exports = {
...require('./mixins/pagination-not-supported'),
name: 'sqlite3',
quote,
compositeKey(parent, keys) {
keys = keys.map(key => `${quote(parent)}.${quote(key)}`);
return keys.join(' || ');
},
handlePaginationAtRoot: async function (parent, node, context, tables) {
const pagingWhereConditions = [];
if (node.orderBy) {
const {
limit,
offset,
order
} = (0, _shared.interpretForOffsetPaging)(node, {
name: 'sqlite3'
});
if (node.where) {
pagingWhereConditions.push(await node.where(`"${node.as}"`, node.args || {}, context, node));
}
tables.push((0, _shared.offsetPagingSelect)(node.name, pagingWhereConditions, order, limit, offset, node.as));
}
}
};