System Information
- Strapi Version: v3.1.4
- Operating System: Mac OS X Catalina
- Database: MongoDB (Locally hosted)
- Node Version: 12.17.0
- NPM Version: 6.14.4
- Yarn Version: 1.22.5
Hi there,
My user model contains a few additional relational fields that I would like to be available and populated when querying ctx.state.user.
Currently the ctx.state.user returns:
{
isActive: true,
blocked: false,
roles: [
{
_id: 5f52761848053351565e8c1f,
name: 'Super Admin',
code: 'strapi-super-admin',
description: 'Super Admins can access and manage all features and settings.',
createdAt: 2020-09-04T17:15:04.302Z,
updatedAt: 2020-09-04T17:15:04.302Z,
__v: 0,
id: '5f52761848053351565e8c1f'
}
],
_id: 5ec9195ae968249eafb6d5ab,
username: 'stephan@test.com',
password: '$2a$10$AJjVSG6SPSqA0z0Npq7vduNJ1SYBeppaHxRhMRzqirI1C9pRvvDB.',
email: 'stephan@test.com',
createdAt: 2020-05-23T12:38:50.372Z,
updatedAt: 2020-09-10T12:10:38.806Z,
__v: 0,
firstname: 'Stephan',
lastname: 'Smith',
id: '5ec9195ae968249eafb6d5ab'
}
The actual user model looks as follow:
How do I update the ctx.state.user to reflect the data from the “isps” relation model?
The response I hope to get will look something like this:
{
isActive: true,
blocked: false,
roles: [
{
_id: 5f52761848053351565e8c1f,
name: 'Super Admin',
code: 'strapi-super-admin',
description: 'Super Admins can access and manage all features and settings.',
createdAt: 2020-09-04T17:15:04.302Z,
updatedAt: 2020-09-04T17:15:04.302Z,
__v: 0,
id: '5f52761848053351565e8c1f'
}
],
_id: 5ec9195ae968249eafb6d5ab,
username: 'stephan@test.com',
password: '$2a$10$AJjVSG6SPSqA0z0Npq7vduNJ1SYBeppaHxRhMRzqirI1C9pRvvDB.',
email: 'stephan@test.com',
createdAt: 2020-05-23T12:38:50.372Z,
updatedAt: 2020-09-10T12:10:38.806Z,
__v: 0,
firstname: 'Stephan',
lastname: 'Smith',
id: '5ec9195ae968249eafb6d5ab',
isp: { // <------- The ISP collection included
_id: 5e234829034823094,
name: 'Mweb',
vlan: 200
}
}
Appreciate any assistance.