@replyke/express
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
20 lines (19 loc) • 692 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = populateList;
const models_1 = require("../models");
async function populateList(list) {
// If a list is found, retrieve the entities using the entityIds array
const entityIds = list.entityIds; // Assuming entityIds is an array of strings
const entities = await models_1.Entity.findAll({
where: {
id: entityIds, // Fetch entities where id is in the entityIds array
},
});
const leanList = list.toJSON();
return {
...leanList,
parentId: leanList.parentId === leanList.userId ? null : leanList.parentId,
entities,
};
}