小程式wafer2操作資料庫
阿新 • • 發佈:2019-01-02
//小程式控制臺phpmyadmin裡給資料庫cAuth新增表 //controllers/hello.js const { mysql } = require('../qcloud') module.exports = async ctx =>{ console.log('exeu sql') var id = 2 //add var book = { id: id, name: "bingyuhuozhige", price:88 } await mysql("Book").insert(book) //search var res = await mysql("Book").where({ id }).first() console.log(res) //update await mysql("Book").update({ price: 66 }).where({ id }) //search var res = await mysql("Book").where({ id }).first() console.log(res) //delete await mysql("Book").del().where({ id }) //search var res = await mysql("Book").where({ id }).first() console.log(res) ctx.state.data = { msg: 'zheng junfei hello' } }