Fix mongo error trying to cast from empty array (#6358)

Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
Alexandre BODIN 2020-05-26 14:29:43 +02:00 committed by GitHub
parent dbaef20ae9
commit 3401348146
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -300,7 +300,11 @@ module.exports = {
const model = getModel(details.model || details.collection, details.plugin);
_.set(acc, attribute, newIds);
if (!Array.isArray(newValue)) {
_.set(acc, attribute, newIds[0]);
} else {
_.set(acc, attribute, newIds);
}
const addPromise = Promise.all(
toAdd.map(id => {