- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我正在使用 Mongoose findOneAndUpdate
但仍然收到错误,
DeprecationWarning: collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead.
但我什至没有使用 findAndModify
,为什么它会将我的查询转换为 findAndModify
?
最佳答案
您需要将查询useFindAndModify
中的选项设置为false
,如docs 中所述.
(搜索关键字目前支持的选项有)
'useFindAndModify': true by default. Set to false to make findOneAndUpdate() and findOneAndRemove() use native findOneAndUpdate() rather than findAndModify().
如果你看到mongoose的定义文件,其中提到它调用findAndModify更新命令。
/**
* Issues a mongodb findAndModify update command.
* Finds a matching document, updates it according to the update arg,
passing any options,
* and returns the found document (if any) to the callback. The query
executes immediately
* if callback is passed else a Query object is returned.
*/
findOneAndUpdate(): DocumentQuery<T | null, T>;
最近在 mongoose 文档 (Click here) 中更新了这些弃用的地方:
Mongoose's findOneAndUpdate() long pre-dates the MongoDB driver's findOneAndUpdate() function, so it uses the MongoDB driver's findAndModify() function instead.
您可以通过三种或更多方式避免使用FindAndModify
:
// Make Mongoose use `findOneAndUpdate()`. Note that this option is `true`
// by default, you need to set it to false.
mongoose.set('useFindAndModify', false);
mongoose.connect(uri, { useFindAndModify: false });
await ModelName.findOneAndUpdate({matchQuery},
{$set: updateData}, {useFindAndModify: false});
关于node.js - DeprecationWarning : collection. findAndModify 已弃用。改用 findOneAndUpdate、findOneAndReplace 或 findOneAndDelete?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52572852/
所以,我有一个 Python 脚本,基本上可以写入 80GB 以上的文件。目前它只是串行运行,在服务器上运行大约需要 13 个小时,这是我唯一一次实际运行它。 我打算将它并行化,以便它写入多个文件,而
我最近将 ASP.Net Web API 项目部署到我们的 Azure 应用服务测试槽,但在向 API 端点发出请求时开始收到错误。通过远程调试,很明显该应用正在从部署的 web.config 文件中
为什么我在 android 的 xml 布局中有这个警告消息 信息是避免使用“px”作为单位,改用“dp” 最佳答案 答案就在那里:What is the difference between "px
我正在使用 Symfony 2.3,并且在我的分析器中有与 Twig 相关的弃用警告。如: DEPRECATION - Using "replace" with character by charac
这个问题在这里已经有了答案: Convert pandas dataframe to NumPy array (15 个答案) 关闭 3 年前。 我有以下代码 train_X, test_X, tr
我正在尝试在 Storyboard完成后运行一些代码,但似乎找不到如何设置它...如果我只是这样做 Completed="LoadingStoryBoard_Completed" 在 Storyboa
我最近使用 ng update 更新了我的 Angular 版本并且在运行 ng lint 时 我收到错误 create is deprecated: use new Observable() ins
我将 webpacker 从 4.x 升级到 5.2.1 并开始收到此警告: The resolved_paths option has been deprecated. Use additional
我正在编译一些 C 代码,但出现错误 typedef 'A' is initialized (use decltype instead) 在我的结构声明之一。什么可能导致这种情况? 最佳答案 我可以用
打开 GUI 的简单程序,单击一个按钮设置 curDir,单击另一个按钮设置 savDir,第三个按钮执行一些 C++ 代码,类似于 ls -l curDir > savDir.txt 我的一个 Qt
我要git diff成为一个快速的命令行解决方案来查看两个文件之间的差异,然后我想要 git difftool启动 meld 以获得文件差异的更多图形 View 。 目前,git diff完全按照我的
我正在尝试构建一个 webpack 解析器,下面的 .plugin 方法代码似乎已被弃用,我找不到使用 .hooks 的类似方法调用。 module.exports = class Resolver
我最近在运行我的应用程序时开始收到此错误。它似乎不会影响一切,但它在日志中非常嘈杂和烦人。我没有对我的应用程序进行任何更改或添加任何会导致此类问题的内容,我最近所做的唯一一件事就是升级到最新版本的 F
我想用 Python mongodb 查询,但“DeprecationWarning: count is deprecated。改用 Collection.count_documents。”给出这样的
代码: export default { props: { article: {type: Object} }, data () { retur
这让我发疯。我想读取一些文本文件(位于我的项目目录之外),用 Windows-1252 编码,将它们编辑为字符串,然后写回这些文件,再次作为 Windows-1252。然而,Visual Studio
我需要一点帮助。因为 preg_replace 已弃用,我必须将所有 my preg_replace 转换为 preg_replace_callback... 我尝试过的: 改变: $template
简短的例子: #include #include using namespace boost; template BOOST_TYPEOF_TPL(T() + U()) add2(const T&
我尝试运行 Vuetify VueJS Cordova example但是在 npm run dev 之后出现了这个错误 node build/dev-server.js Starting dev s
我有以下代码: func setupShortcutItems(launchOptions: [NSObject: AnyObject]?) -> Bool { var shouldPerfo
我是一名优秀的程序员,十分优秀!