参考: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. 日常学习-001-Get和Post的区别

    首先说明参考链接:https://mp.weixin.qq.com/s/W68JzNIoUpm9hyXinOzkMw 以下为个人观后总结. 初级理解: GET和POST的区别 1.get传送的参数长度 ...

  2. jieba分词处理

    分词是一种数学上的应用,他可以直接根据词语之间的数学关系进行文字或者单词的抽象,比如,讲一句话"我来自地球上中国"进行单词分割,我们可能会得到如下的内容:"我" ...

  3. Spring RestTemplate 之exchange方法

    ●exchange方法提供统一的方法模板进行四种请求:POST,PUT,DELETE,GET (1)POST请求 String reqJsonStr = "{\"code\&quo ...

  4. Java电话薄项目(Java基础入门)

    面向对象程序设计(Java基础) 1.项目介绍: 该项目能够实现对电话薄的添加,查找,修改,删除,排序等基本操作. 用户进入系统中首先进入主菜单中,在主菜单中可以选择相应的操作,用户可以选择每项操作前 ...

  5. TCP协议与HTTP协议区别

    一.TCP协议与HTTP协议区别 1.直观认识 TCP协议对应于传输层,而HTTP协议对应于应用层,从本质上来说,二者没有可比性.Http协议是建立在TCP协议基础之上的,当浏览器需要从服务器获取网页 ...

  6. shell脚本(11)-流程控制case

    一.case介绍 生产环境下,遇到要根据不同的状况执行不同的预案的情况,首先根据可能出现的情况写出对应预案,根据出现的情况来加载不同的预案 特点:根据给予的不同的代码块 二.case语法 case 变 ...

  7. 第二十五篇 -- C++宝典中的图书管理系统

    此篇文章是基于C++宝典写的图书管理系统,本人对其中的部分做了相应修改,并且以现有格式替代原有格式,使程序更加清晰明了.此程序运行在VS2017上. 系统设计 图书管理系统分为四个模块:图书管理模块. ...

  8. 构建前端第10篇之---Function.prototype.call()

    张艳涛写于2020-01-25,参考:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/ ...

  9. markdown文档编写基础

    Markdown快速入门教程 ###########来源:https://zhuanlan.zhihu.com/p/84918488 ###########来源:https://github.com/ ...

  10. Jmeter分布式压测实战及踩坑处理(含参数化)

    项目中使用Jmeter进行大并发压测时,单机受限内存.CPU.网络IO,会出现服务器压力还没有上 去,但压测服务器由于模拟的压力太大死机的情况.JMeter的集群模式可以让我们将多台机器联合起来 一起 ...