List users for the current account
In a server controller, call user.get({ account: req.account }) to fetch the members of the authenticated account. The existing GET /api/account/users handler in controller/accountController.js uses this query and returns pending invitations separately:
const user = require('../model/user');
const invite = require('../model/invite');
exports.users = async function (req, res) {
const users = await user.get({ account: req.account });
const invites = await invite.get({ account: req.account, returnArray: true, used: false });
return res.status(200).send({ data: { users, invites } });
};
How the models find account members
- SQL (Knex) —
model/sql/user.jsjoinsuser.idtoaccount_users.user_idand filters by the membership row’saccount_id. - MongoDB (Mongoose) —
model/mongo/user.jsqueries the user collection withUser.find({ 'account.id': account }). Each user document stores its account memberships in theaccountarray.