参考: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. MySQL 那些常见的错误设计规范

    依托于互联网的发达,我们可以随时随地利用一些等车或坐地铁的碎片时间学习以及了解资讯.同时发达的互联网也方便人们能够快速分享自己的知识,与相同爱好和需求的朋友们一起共同讨论. 但是过于方便的分享也让知识 ...

  2. Linux sudo命令——sudoers文件的配置

    Linux sudo命令与其配置文件/etc/sudoers   对linux有一定了解的人多少也会知道点关于sudo命令.sudo命令核心思想是权限的赋予 ,即某个命令的所属用户不是你自己,而你却有 ...

  3. C语言:float表示范围

    #include <stdio.h> #include <limits.h> //整数限制 #include <float.h> //浮点数限制 void main ...

  4. P3203 弹飞绵羊-分块

    P3203 弹飞绵羊-分块 观察数据范围,发现可以分块.只需要处理每个点跳出所在块后的位置和次数即可.目的是为了加速查询并降低修改复杂度. 对于修改,重构整个块内信息即可. 时间复杂度正确的一批 具体 ...

  5. SSM和Maven整合

    项目架构如图 applicationContext.xml还有其他文件一起放进resources下 jsp,js,等文件放在webapp下

  6. vue函数式组件详解

    本篇将详细介绍vue组件化之函数式组件,会用到以下api: Vue.component().Vue.extend().$createElement.patch(). 从事vue开发的小伙伴,平时组件化 ...

  7. 通过jstack日志分析和问题排查

    简介 jstack用于生成java虚拟机当前时刻的线程快照.线程快照是当前java虚拟机内每一条线程正在执行的方法堆栈的集合,生成线程快照的主要目的是定位线程出现长时间停顿的原因,如线程间死锁.死循环 ...

  8. ThinkPHP5 SQL注入漏洞 && 敏感信息泄露

    访问看到用户名被显示了 http://192.168.49.2/index.php?ids[]=1&ids[]=2 访问http://your-ip/index.php?ids[0,updat ...

  9. Matlab的datenum()函数用法

    Matlab的datenum()函数用法 将日期和时间转换为日期序列值 datenum 函数创建一个数值数组,将每个时间点表示为从 0000 年 1 月 0 日起的天数.数值还能表示以天为单位的过去时 ...

  10. netty系列之:netty中的Channel详解

    目录 简介 Channel详解 异步IO和ChannelFuture Channel的层级结构 释放资源 事件处理 总结 简介 Channel是连接ByteBuf和Event的桥梁,netty中的Ch ...