参考: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. spring boot 集成mqtt

    1.pom文件中添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifact ...

  2. DEV-C++ 5.11调试设置方法

    DEV-C++调试设置方法:默认不能调试,打开调试的方法: 1.点击"工具"菜单--编译选项--"代码生成/优化"--连接器--"产生调试信息&quo ...

  3. 【论文阅读】套娃之 Blog for DMP Dynamic Movement Primitives

    前言:原笔记Notion链接:https://www.notion.so/Blog-for-DMP-d34e83c05eb944ba989fc8bf9b0c0f7b 如有格式显示问题等请点击此处查看 ...

  4. 【论文阅读】End to End Learning for Self-Driving Cars

    前言引用 [1] End to End Learning for Self-Driving Cars从这里开始 [1.1] 这个是相关的博客:2016:DRL前沿之:End to End Learni ...

  5. Spring Boot邮箱链接注册验证

    Spring Boot邮箱链接注册验证 简单介绍 注册流程 [1]前端提交注册信息 [2]后端接受数据 [3]后端生成一个UUID做为token,将token作为redis的key值,用户数据作为re ...

  6. Leetcode:面试题28. 对称的二叉树

    Leetcode:面试题28. 对称的二叉树 Leetcode:面试题28. 对称的二叉树 Talk is cheap . Show me the code . /** * Definition fo ...

  7. tomcat的单例多线程代码示例(十)

    一.懒汉式单例多线程模式 1.创建模拟的servlet生成器 package cn.bjsxt.sing; import java.util.UUID; public class LszySingle ...

  8. [考试总结]noip模拟26

    首先看到这样中二的题目心头一震.... 然而发现又是没有部分分数的一天. 然而正解不会打.... 那还是得要打暴力. 但是这套题目有两个题目只有一个参数. 所以... (滑稽).jpg 然后我就成功用 ...

  9. 手把手教你玩转HarmonyOS版地图应用开发

    ​一.导读 7月31日,华为HarmonyOS开发者日将在杭州举行.为了方便更多开发者,高德开放平台地图SDK已在业内率先实现鸿蒙化迁移和重构,全面适配HarmonyOS并面向开发者免费发布.开发者可 ...

  10. anyRTC Web SDK 实现音视频呼叫功能

    前言 大家好,今天小编带给大家一个基于 anyRTC Web SDK 实现音视频呼叫的功能(本项目采用vue开发). 前提条件 在开始写代码之前还需要做一些准备工作,如果你之前没有使用过 anyRTC ...