admin管理员组文章数量:1125775
I am facing this issue where I have appointments and customers and contacts and while getting an appointment I am using populate to populate the customer from appointment,
The issue is it has been working fine for 3 years but suddenly I am facing an issue where sometimes the populate is returning the customer and sometimes it's returning null, even though data exists in the db.
I am calling it again and again and 4 out of 10 times the populate is returning null.
I tried to find a possible solution couldn't find any, any insight will be helpful.
await this.model.findOne({ _id: appointmentId }).sort({}).select('-_v').populate([
{
path: 'customer.customerId',
model: 'Customers',
select:
'vehicles firstName lastName fullNameQBO isFleetCustomer isMFCustomer fleetNumber companyName contactOnEmail contactOnPhone email phone phone2 notes contactId taxExempt preferredLocation',
populate: {
path: 'contactId',
model: 'Contacts',
select: 'contactInfo',
},
},
{
path: 'vehicle.vehicleId',
model: 'Vehicles',
select: 'year VIN model make engine isActive transmission ODM licensePlateNo vehicleName',
},
{
path: 'estimate.estimateId',
model: 'RepairOrders',
select: 'code title estimateBy createdAt vehicle',
},
]).lean(true);
本文标签: nodejsMongoDB populate sporadically not working for same datasetStack Overflow
版权声明:本文标题:node.js - MongoDB populate sporadically not working for same dataset - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736674713a1947117.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论