Вы посмотрели на решение, данное @wch (W. Chang)?
https://github.com/hadley/ggplot2/issues/743
Я думаю, что он лучший
по существу похож на файл @baptiste, но включает ссылку на среду непосредственно в вызове ggplot
. Я сообщаю об этом здесь
g <- function() {
foo3 <- 4
ggplot(mtcars, aes(x = wt + foo3, y = mpg),
environment = environment()) +
geom_point()
}
g()
# Works
ну, вы можете изменить способ, которым вы делаете свою помощницу по обновлению .. Я предлагаю вам использовать findOne (), а затем использовать update для вашего Пользователя, потому что при этом вы имеете больший контроль над обновлением, чем просто с помощью update .. так что попробуйте вот так
UploadImage(req, res) {
User.findOne({ _id: req.user._id })
.then((user) => {
if (user) {
if (user.images.type.length <= 4) {
cloudinary.uploader.upload(req.body.image, async result => {
user.image.type.push({ imgId: result.public_id, imgVersion: result.version });
user.save()
.then(res.status(HttpStatus.OK).json({ message: 'Image uploaded successfully' }))
.catch(); //use callback inside save() or use it like promise
});
}
} else { res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({ message: 'Error uploading image' }); }
})
.catch(err => res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({ message: 'Error uploading image' }));
}
, сделав это так, вы можете достичь того, что вы ищете .. ура :))