// 引入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. Fluentd采集示例

    Fluentd通过读取配置文件来加载各插件,日志经由各插件的处理完成输入到输出的整个路由. 本文通过一个最简单的示例来说明配置文件的结构.td-agent.conf默认位于/etc/td-agent/ ...

  2. js基础知识--BOM

    之前说过,在js的 运行环境为浏览器时,js就主要有三部分组成: ECMAScript核心语法.BOM.DOM.今天就和大家详细说一下BOM的一些基础知识. BOM BOM通常被称为浏览器对象模型,主 ...

  3. Android类加载流程

    背景 由于前前前阵子写了个壳,得去了解类的加载流程,当时记了一些潦草的笔记.这几天把这些东西简单梳理了一下,本文分析的代码基于Android8.1.0源码. 流程分析 从loadClass开始,我们来 ...

  4. 关于windows-server-下MySQL Community版本的的安装与配置

    在公司电脑或者服务器上安装软件,都是有要求的,要么购买license-(这个需要申请,难度较大),要么安装免费开源的软件 笔者最近想要安装mysql服务环境,用于数据存储及开发一些功能程序需要连接数据 ...

  5. IPv4 与 IPv6的区别

    在介绍 IPv4 到 IPv6 区别之前,我们先来简单了解一下 IPv4 和 IPv6. IPv4 网际协议版本4(英语:Internet Protocol version 4,IPv4),又称互联网 ...

  6. win7升级到win10系统后,node13升级为node16,node版本node-sass版本与不匹配,导致出现npm ERR! ERESOLVE could not resolve

    1. 错误npm ERR! code ERESOLVE 系统从win7升级到win10,之前的node版本是13.14.0,现在版本是16.17.1.正常的vue程序无法正常运行.从网上查询得知&qu ...

  7. 2022-08-25-cdn套中套

    layout: post cid: 19 title: cdn套中套 slug: 19 date: 2022/08/25 20:32:00 updated: 2022/08/26 11:20:20 s ...

  8. Linux基础_4_文件夹管理

    文件路径 . #表示当前目录,同./ .. #表示上级目录,同../ ../../ #表示上上级目录 / #表示根目录 注:文件名长度不超过255个字符 注:.开头为隐藏文件 切换目录 cd #默认切 ...

  9. python批量加密文件

    1.文件名的加密与解密 #coding:utf-8 from docx import Document import os,sys from docx.oxml.ns import qn def fi ...

  10. scrapy 如何使用代理 以及设置超时时间

    使用代理 1. 单文件spider局部使用代理 entry = 'http://xxxxx:xxxxx@http-pro.abuyun.com:xxx'.format("帐号", ...