I'm trying to find a existing user using mongoose My query is
UserAccount.find(variables, function (error, success) {
if (error) {
response.send({status: false});
} else {
console.log(success);
}
});
If user exists means it returns following array.
[ model {
'$__':
InternalCache {
strictMode: true,
selected: [Object],
shardval: undefined,
saveError: undefined,
validationError: undefined,
adhocPaths: undefined,
removing: undefined,
inserting: undefined,
saving: undefined,
version: undefined,
getters: {},
_id: 5c98e64f2106e94022532c9f,
populate: undefined,
populated: undefined,
wasPopulated: false,
scope: undefined,
activePaths: [StateMachine],
pathsToScopes: {},
session: null,
ownerDocument: undefined,
fullPath: undefined,
emitter: [EventEmitter],
'$options': [Object] },
isNew: false,
errors: undefined,
_doc:
{ isActive: true,
_id: 5c98e64f2106e94022532c9f,
userName: '[email protected]',
password:
'$2a$05$vpowA76cB3T/4eHGbQPqd.F/iIebX7SXKPZA2k1wcmlSIDks0q852',
userCategory: 'buyer',
createdDate: 2019-03-20T14:31:43.250Z,
updatedDate: 2019-03-20T14:31:43.250Z,
__v: 0 },
'$init': true } ]
I don't know what is causing this problem? Until yesterday it returned only the user data, but this is so strange to me. How to fix this problem? Can some one help me to fix this please? Thank you.
You simply get rid this by using lean() at the end of query
const courses = await Course
.find({ isPublished: true })
.or([
{ price: { $gte: 15 } },
{ name: /.*by.*/i }
]).lean(); // use lean to remove unnecessary values from output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With