this.app.mysql.get("data_options", {value: "xxx"}); // 查询一个内容this.app.mysql.insert("i18n_config", [{...}]); // 批量添加this.app.mysql.select("i18n_config", { where: { id: 10000 } });await this.app.mysql.update('i18n_comment', { id: i18nComment.id, // 修改时,一定需要id作为索引进行修改 comment, en_unique_md5, cn_value: cnValue,});await this.app.mysql.select("select * from i18n_config_status_data where id = ?", [1000]),
事务
const conn = yield app.mysql.beginTransaction();try { yield conn.insert(table, row1); yield conn.update(table, row2); yield conn.commit();} catch (err) { // error, rollback yield conn.rollback(); // rollback call won't throw err throw err;}const result = yield app.mysql.beginTransactionScope(function* (conn) { // don't commit or rollback by yourself yield conn.insert(table, row1); yield conn.update(table, row2); return { success: true };}, ctx); // ctx is the context of current request, access by `this.ctx`.// if error throw on scope, will auto rollback