Introduction mongodb-plus

mongodb-plus是一个为简化Node.js中MongoDB操作创建的插件,它基于mongodb原生方法封装,高度兼容并提供同步(以Sync结尾的方法)和Promise(无Sync的方法)两种方式。相较于mongoose,它没有模型对象限制输入数据,提供更自由的操作体验。本文将介绍其安装、连接MongoDB、方法使用示例。
摘要由CSDN通过智能技术生成
Introduction mongodb-plus
  • This is a plugin that was created to make it easy to operate the mongodb database in nodejs,Maybe everyone has heard of mongoose, indeed mongoose is also very good, but there are model objects in mongoose that limit the input data. I don’t like this limitation very much, so I created this plugin 23333.
  • I am encapsulating based on the native method of mongodb,It is highly compatible with the original method, but it is more convenient,The method is named the same as the native method, so that you can get started directly,The method I divided into two types:One is an improved native method (with Sync ending)The other is based on Promise encapsulation (without Sync),Can be used in conjunction with async asynchronous function (comfortable with koa)
  • This plugin is essentially a syntactic sugar,Is that you can use nodejs to operate the mongodb database more convenient,But essentially the native mongodb method, so there is no change in performance
Use of mongodb-plus
1. installation

npm i mongodb-plus

2. Connect mongodb
//import mongodb-plus
const db = require("mongodb-plus")
//The way to connect to the database is the same as the native,I don't make too many changes here
db.connect("mongodb://localhost:10086/demo1").then(()=>{
   
    console.log("connected...")
}).catch
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值