gpt4 book ai didi

javascript - ( Node :71307) [DEP0079] DeprecationWarning

转载 作者:IT老高 更新时间:2023-10-28 13:17:29 25 4
gpt4 key购买 nike

尝试更新 MongoDB 文档获取弃用警告为

(node:71307) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated

Node 版本v10.5.0,数据库版本 v3.6.5, Mongoose 版mongoose@4.1.12

Campground.findById(campgroundId, function(err, campground){
if(err){
console.log(err);
} else {
console.log(campground.celebrity);
Celebrity.create(celebrityData, function(err, celebrity){
if(err){
console.log(err);
} else {
//save comment
celebrity.save();
campground.celebrity.push(celebrity);
campground.save();
console.log(celebrity);
//req.flash('success', 'Created a comment!');
}
});
}
});

最佳答案

你不必担心这个错误,这是 Mongoose 警告。实际上 Mongoose 使用 inspect() 来调试输出。他们可能会在 Node 12.x 之前更新它。目前使用它是安全的。

不用担心。

检查此信息。 https://nodejs.org/api/deprecations.html#deprecations_dep0079_custom_inspection_function_on_objects_via_inspect

DEP0079: Custom inspection function on Objects via .inspect()# Type: Runtime

Using a property named inspect on an object to specify a custom inspection function for util.inspect() is deprecated. Use util.inspect.custom instead. For backward compatibility with Node.js prior to version 6.4.0, both may be specified.

如果您想了解更多详细信息,请参阅此。这正在进行中。警告将出现在 Node 10

https://github.com/Automattic/mongoose/issues/6420

关于javascript - ( Node :71307) [DEP0079] DeprecationWarning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51436073/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com