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