From 6c2ea87030b308306edee5047db3288eb8ab6087 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Mon, 23 Dec 2019 20:40:05 +0800 Subject: [PATCH] find --- controllers/index.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/controllers/index.js b/controllers/index.js index e119933..6525c76 100644 --- a/controllers/index.js +++ b/controllers/index.js @@ -53,12 +53,29 @@ var dellist = async (ctx,next)=>{ ctx.body = JSON.stringify(res) }) } - +} +var findlist = async (ctx,next)=>{ + // console.log(ctx.query.id) + if(ctx.query.name == undefined){ + ctx.body = JSON.stringify({ + code : 1, + msg:"id不能为空" + }) + }else{ + await dbs.find('list',{ + "name":ctx.query.name + }).then((res)=>{ + ctx.body = JSON.stringify(res) + }).catch((err)=>{ + ctx.body = JSON.stringify(res) + }) + } } module.exports = { 'GET /getlist':getlist, 'POST /addlist':addlist, 'GET /getaddlist':getaddlist, - 'GET /dellist' : dellist + 'GET /dellist' : dellist, + 'GET /findlsit':findlist }