参考:mongoose报错:DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead

mongoose报错:
(node:9716)DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead

解决方法:

// 导入第三方模块mongoose
const mongoose = require('mongoose'); // mongoose.set('useCreateIndex', true) //加上这个
// 或连接数据库时添加 useCreateIndex: true
 mongoose.connect('mongodb://Jacey:123@localhost:27017/blog2', { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true }) .then(() => console.log('数据库链接成功')) .catch(err => console.log('数据库连接失败:', err));

mongoose报错:DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead的更多相关文章

  1. mongoose报错:DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.

    mongoose报错:(node:15689) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes ...

  2. mongoose 报错:DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead

    mongoose.set('useCreateIndex', true)    // 加上这个

  3. [未解决]报错:DeprecationWarning: decodestring() is a deprecated alias since Python 3.1, use decodebytes()

    DeprecationWarning: decodestring() is a deprecated alias since Python 3.1, use decodebytes()

  4. 【PHP】php7.2报错The each() function is deprecated. This message will be suppressed on furthe

    php7.2以上 废除了 each()方法,项目中用到的地方会出现以下报错 The each() function is deprecated. This message will be suppre ...

  5. phpredis 报错 “Function Redis::setTimeout() is deprecated” 解决方法

    项目在本地开发过程中抛出异常: Function Redis::setTimeout() is deprecated 找到出错代码: <?php use Illuminate\Support\F ...

  6. Vivado_HLS 编译报错error: AP_STREAM macros are deprecated

    D:/vivado2018.3/Vivado/2018.3/common/technology/autopilot\ap_stream.h:62:2: error: AP_STREAM macros ...

  7. DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead extract-text-webpack-plugin 提取css报错

    深入浅出Webpack 1-5 使用pulugin extract-text-webpack-plugin 提取css报错 DeprecationWarning: Tapable.plugin is ...

  8. mybatis报错Mapped Statements collection does not contain value for com.inter.IOper

    首页 > 精品文库 > mybatis报错Mapped Statements collection does not contain value for com.inter.IOper m ...

  9. php报错日志:PHP Deprecated:Automatically populating $HTTP_RAW_POST_DATA is deprecated

    前几天将线上php服务升级到5.6.x版本后,php-error.log报出错误:PHP Deprecated: Automatically populating $HTTP_RAW_POST_DAT ...

随机推荐

  1. Linux | 文件编辑命令

    cat cat 命令是是一次性显示文件的所有内容 cat 是 concatenate 的缩写,表示:连接/串联 cat 文件名 可以看到,cat 命令是一次性显示出所有的文件内容,这就导致了,有的文件 ...

  2. iPhone X适配方案

    iPhone X适配方案 https://github.com/Wscats/iPhone-X 绝对长度单位 英寸 厘米 毫米 磅 pc inch cm mm pt pica 相对长度单位 是网页设计 ...

  3. C语言:获取汉字的编码

    #include <stdio.h> #include <locale.h> #include <wchar.h> int main() { setlocale(L ...

  4. 【译】.NET 对象分配工具

    随着 Visual Studio 16.10 的发布,性能分析器又有了一个新的分析引擎,.NET 对象分配工具是第一个加入的工具.这为该工具提供了一些新特性,并显著提高了 perf 性能.在你的 C# ...

  5. debian 9 pycharm安装

    官网下载PyCharm的tar.gz格式 使用命令进行解压:tar -xvzf pycharm.tar.gz 解压后将pycharm文件夹移动到/usr/local/lib/目录下 进入pycharm ...

  6. nacos Connection refused (Connection refused)

    记录一次"异常bug",具体信息如下.主要是记录一下处理过程,可能口水话比较多,如果想看结果,直接往后拉即可. 最后一行 起初,运维同事找到我,跟我说程序出问题了,系统升级,一直连 ...

  7. Geoserver通过ajax跨域访问服务数据的方法(含用户名密码认证的配置方式)

    Goeserver数据有两种,一种需进行用户密码的权限认证,一种无须用户密码.对于网上跨域访问Geoserver数据的种种方法,对这2种数据并非通用. 笔者将Geoserver官方下载的Geoserv ...

  8. 第三篇 -- Go语言其他类型转String方法

    1. int转string // 法1: int转string num_int := 10 num_str_2 := fmt.Sprintf("%b", num_int) fmt. ...

  9. python -- 负数平方根-虚数的使用

    负数的平方根是虚数. 不能使用sqrt,因为它只能处理浮点数,而虚数是完全不同的--这也是由另外一个叫做cmath(即 complex math, 复数)的模块来实现这些功能的原因. >> ...

  10. 14Java进阶网络编程API

    1.网络协议的三要素:语义.语法和时序 语义表示要做什么,语法表示要怎么做,时序表示做的顺序. 2.网络OSI七层模型 OSI/RM 模型(Open System Interconnection/Re ...