Autopopulate is failing when the autopopulated field is an empty array.
In my Project Schema the field "clients" doesn't always have values. Some projects have clients others don't.
When I try the mongoose function "findOneAndUpdte" it fails and the message is:
(node:11503) UnhandledPromiseRejectionWarning: CastError: Cast to [ObjectId] failed for value "[""]" at path "clients"
Hello
Autopopulate is failing when the autopopulated field is an empty array.
In my Project Schema the field "clients" doesn't always have values. Some projects have clients others don't.
When I try the mongoose function "findOneAndUpdte" it fails and the message is:
(node:11503) UnhandledPromiseRejectionWarning: CastError: Cast to [ObjectId] failed for value "[""]" at path "clients"
Fails only on update. On Find it works OK.