@url = http://localhost:3000
@json = Content-Type: application/json
### 查询
router.get("/tag",async (ctx)=>{
try{
const data =await tagModel.find({});
return success(ctx,data);
} catch(error){
return fail(ctx,error);
}
GET {{url}}/tag
### 添加
router.post("/tag",async ctx=>{
try{
const data =await tagModel.create(ctx.request.body);
return success(ctx,data);
} catch(error){
return fail(ctx,error);
}
POST {{url}}/tag
{{json}}
{
"text":"张三"
}
### 删除
router.delete("/tag",async ctx=>{
try{
const data =await tagModel.deleteOne(ctx.request.body);
return success(ctx,data);
} catch(error){
return fail(ctx,error);
}
DELETE {{url}}/tag?_id:61a8881b29f6dd1d230327fc
{{json}}
### 修改内容
router.put("/user",async ctx=>{
try{
const data =await userModel.updateOne(ctx.query,ctx.request.body);
return success(ctx,data);
} catch(error){
return fail(ctx,error);
}
PUT {{url}}/content?_id=61a8823b29f6dd1d230327c2
{{json}}
{
"top":true
}