1.controllersql
const {ctx,service} = this;
let id = ctx.query.id // 獲取GET的參數
let body = ctx.request.body // 獲取POST的參數
2.service中的增刪改查this
let insertAuth = await ctx.basmodel.query(sql,{type:'INSERT'})
let insertAuth = await ctx.basmodel.query(sql,{type:'UPDATE'})
let insertAuth = await ctx.basmodel.query(sql,{type:'DELETE'})
let insertAuth = await ctx.basmodel.query(sql,{type:'SELECT'})
3.Sequelize經常使用方法:spa
let insert = await ctx.basmodel.GoodsCategoryModel.create()//添加
let insert = await ctx.basmodel.GoodsCategoryModel.update({where:id})//修改
let insert = await ctx.basmodel.GoodsCategoryModel.destroy({where:id})//刪除
let insert = await ctx.basmodel.GoodsCategoryModel.findAll({where:id})//查詢