node.js封装数据库增删改查
数据库增删改查的封装 小编不容易 const sql = { insert: function (Collection, insertData) { return new Promise((resolve, reject) => { Collection.insertMany(insertData, (err) => { if (err) throw err; resolve() }) }) }, find (Collection, whereObj, showObj) { // return new Promise(function (resolve, reject) {}) // return new Promise(function (resolve, reject) { // 异步操作}) // return new Promise(function (resolve, reject) { // 异步操作 - reslove(data)}) return new Promise(function (resolve, reject) { Collection.find(whereObj, showObj).exec((err, data) => { if (err) throw err; resolve(data) }) }) }, sort: function *