Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

[WIP] Lists with all records in a multiple-section #108

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/models/section.js
Expand Up @@ -211,11 +211,19 @@ module.exports = (sequelize, DataTypes) => {
*/
Section.contentFor = async function contentFor(args, recordId) {
const [limit, where, order] = (() => {
if (recordId) {
return [1, { id: recordId }, null];
if (!recordId || (args.params.innersection === 'true' && args.params.excludeself !== 'true')) {
return [Utils.toNumber(args.params.limit) || DEFAULTS.limit, {},
_orderBy(args.params.order)];
}

return [Utils.toNumber(args.params.limit) || DEFAULTS.limit, {}, _orderBy(args.params.order)];
if (recordId && args.params.innersection === 'true' && args.params.excludeself === 'true') {
return [Utils.toNumber(args.params.limit) || DEFAULTS.limit, {
[Op.not]: {
id: [recordId],
},
},
_orderBy(args.params.order)];
}
return [1, { id: recordId }, null];
})();
const offset = Utils.toNumber(args.params.offset) || DEFAULTS.offset;

Expand Down