// 引入mongoose模块
const mongoose = require('mongoose');
// 链接数据库
mongoose.set('useCreateIndex', true) //加上这个
mongoose.connect('mongodb://localhost/xxxxxxxxx',{useNewUrlParser: true,useUnifiedTopology: true})
        .then(()=>console.log('数据库连接成功'))
        .catch(()=>console.log('数据库连接失败'))

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报错:DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead mo ...

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

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

  4. Python提示AttributeError 或者DeprecationWarning: This module was deprecated解决方法

    Python提示AttributeError 或者DeprecationWarning: This module was deprecated解决方法 在使用Python的sklearn库时,发现sk ...

  5. 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 ...

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

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

  7. koa2入门(3)mongoose 增删改查

    项目地址:https://github.com/caochangkui/demo/tree/koa-mongoose 连接数据库 数据库名字为:koa-mongoose const mongoose ...

  8. Centos下,Docker部署Yapi接口管理平台

    前言介绍 Yapi 由 YMFE 开源,旨在为开发.产品.测试人员提供更优雅的接口管理服务,可以帮助开发者轻松创建.发布.维护 API. 项目地址:https://github.com/YMFE/ya ...

  9. 手把手教你基于koa2,mongoose实现增删改查

    初始化项目 npm init -y 先安装一波乱七八糟的依赖插件(需要具备一定的koa2知识,至于mongoDB自行百度安装教程),模板引擎我使用的是art-template(据说是性能最好的,而且是 ...

  10. node.js操作数据库之MongoDB+mongoose篇

    前言 node.js的出现,使得用前端语法(javascript)开发后台服务成为可能,越来越多的前端因此因此接触后端,甚至转向全栈发展.后端开发少不了数据库的操作.MongoDB是一个基于分布式文件 ...

随机推荐

  1. CentOS7.9 yum方式安装redis最新版

    yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm yum --enablerepo=remi ins ...

  2. Elasticsearch 架构解析与最佳实践

    文章转载自:https://mp.weixin.qq.com/s/7pWNsUYbM4NyubZO6M3P5g

  3. k8s中使用到的各种证书图示

  4. 关于Linux下aws-cli-2版本的安装

    AWS CLI 版本 2 是 AWS CLI 的最新主版本,支持所有最新功能.版本 2 中引入的某些功能无法向后兼容版本 1,您必须升级才能访问这些功能. AWS CLI 版本 2 仅可作为捆绑安装程 ...

  5. Mybatis PageHelper 使用的注意事项

    什么时候会导致不安全的分页? PageHelper 方法使用了静态的 ThreadLocal 参数,分页参数和线程是绑定的. 只要你可以保证在 PageHelper 方法调用后紧跟 MyBatis 查 ...

  6. 常见的 Kerberos 错误消息

    常见的 Kerberos 错误消息 问题:All authentication systems disabled; connection refused 原因:此版本的 rlogind 不支持任何验证 ...

  7. 2022-08-12-esp32把玩记-②_用Micropython点ssd1306_oled屏幕

    layout: post cid: 8 title: esp32把玩记-② 用Micropython点ssd1306 oled屏幕 slug: 8 date: 2022/08/12 15:12:39 ...

  8. Java 求解自幂数(水仙花数)

    什么是自幂数 如果在一个固定的进制中,一个 n 位自然数等于自身各个数位上数字的 n 次幂之和,则称此数为自幂数. 例如:在十进制中,153 是一个三位数,各个数位的3次幂之和为 1^3+5^3+3^ ...

  9. 在vue项目中禁用eslint

    文章目录 1.在创建项目的时候不自动使用eslint 2.在package.json中删除所有的eslint,然后重新install 3.按照图片注释(亲测可用) 在使用eslin进行规则验证时,一点 ...

  10. mybatis-核心配置文件讲解

    核心配置文件详解 核心配置文件中的标签必须按照固定的顺序(有的标签可以不写,但顺序一定不能乱): properties.settings.typeAliases.typeHandlers.object ...