From 92d82c08ddf736fab19a5852e03aa058318f5e15 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Wed, 13 Nov 2019 11:11:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/mongodb.js | 4 +--- controllers/login.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/mongodb.js b/bin/mongodb.js index d7e084b..5c5571b 100644 --- a/bin/mongodb.js +++ b/bin/mongodb.js @@ -1,8 +1,6 @@ var MongoClient = require('mongodb').MongoClient; var dburl; let add = (set,data,url = dburl) =>{ - // console.log(url) - return new Promise((resolve, reject) => { MongoClient.connect(url.url, { useUnifiedTopology: true, useNewUrlParser: true}, function(err, db) { if (err) throw err; @@ -99,7 +97,7 @@ let find = (set,where = {},page = 0,num = 0,url = dburl) =>{ if (err) throw err; var dbo = db.db(url.dbname); try { - dbo.collection(set). find(where).skip(num * page).limit(num).toArray(function(err, result) { // 返回集合中所有数据 + dbo.collection(set). find(where).skip(num * page).limit(num).toArray(function(err, result) { if (err) throw err; resolve({code:0,data:result}); db.close(); diff --git a/controllers/login.js b/controllers/login.js index ee9cddb..e69ff08 100644 --- a/controllers/login.js +++ b/controllers/login.js @@ -12,7 +12,7 @@ var loginup = async (ctx,next) => { }) } //判断用户名密码 - if(ctx.request.body.name == arr[i].name && ctx.request.body.pwd == arr[i].pwd){ + if(ctx.request.body.name == arr[0].name && ctx.request.body.pwd == arr[0].pwd){ //颁发token const token = jwt.sign({ name: ctx.request.body.name,