I\'m using Mongoose.js to create models with schemas.
I have a list of models (many) and at times I\'d like to get the attributes/keys that make up a particular mo
In case you want to have all property values (including nested and populated properties), just use toObject() method:
let modelAttributes = null;
SomeModel.findById('someId').populate('child.name').exec().then((result) => {
modelAttributes = result.toObject();
console.log(modelAttributes);
});
The output would be:
{
id: 'someId',
name: 'someName',
child: {
name: 'someChildName'
}
...
}