This repository has been archived on 2025-11-04. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
know-it-all/server/routes/org/GetOrg.js
2022-03-30 09:46:43 -05:00

35 lines
899 B
JavaScript

const { Organization } = require('../../models/index');
async function GetOrg(req, res, next) {
const user = req.user;
const orgID = req.params.orgID;
const org = await Organization.findByPk(orgID, {
attributes: { exclude: ['updatedAt'] },
include: [
{
association: 'orgOwner',
attributes: {
exclude: ['userID', 'password', 'createdAt', 'updatedAt'],
},
},
{
association: 'orgMember',
attributes: {
exclude: ['password', 'createdAt', 'updatedAt'],
},
required: false,
},
],
});
const status = org.ownerID == user.userID;
return res.send({
org,
memberCount: org.orgMember.length,
status,
});
}
module.exports = GetOrg;