饮水记录长按删除功能,修复食谱详情中搭配推荐t食品跳转问题

This commit is contained in:
2022-01-20 16:06:30 +08:00
parent edcf04b7e2
commit e7807e9709
7 changed files with 993 additions and 1118 deletions

View File

@@ -2,7 +2,7 @@
* 对 SQLite 的 ORM 的封装处理
* @time 2021-12-30 11:00:00
* @version 2.0.0
*
*
* @by onemue
*/
@@ -38,9 +38,9 @@ class Utils {
}
}
Utils.log(primaryKeyArr.length);
if (primaryKeyArr.length >= 1) {
if (primaryKeyArr.length>=1) {
sql = `CREATE TABLE '${name}' (${sqlArr.join(', ')}, PRIMARY KEY (${primaryKeyArr.join()}))`;
} else {
}else{
sql = `CREATE TABLE '${name}' (${sqlArr.join(', ')})`;
}
Utils.log(`modelSql :${sql}`);
@@ -119,7 +119,7 @@ class Model {
* @constructor
* @param {String} name 数据库表名
* @param {Object} options 数据表列对象
* @returns
* @returns
*/
constructor(name, options) {
let self = this;
@@ -135,11 +135,11 @@ class Model {
/**
* @description 查询表数据
* @param {String|Array} options
* @param {String|Array} options
* - String WHERE 内容
* - Array 需要查询的列
* @param {*} callback
* @returns
* @param {*} callback
* @returns
*/
find(options, callback) {
let sql = '';
@@ -173,7 +173,7 @@ class Model {
/**
* @description 分页查询
* @param {Object} options : { where:查询条件, number: 当前页数 , count : 每页数量 }
* @param {Function} callback :err,results=>{}
* @param {Function} callback :err,results=>{}
* @return
*/
limit(options, callback) {
@@ -223,7 +223,7 @@ class Model {
} else if (options.constructor == Object) {
let keys = [];
let values = [];
let index = arguments[3] ?? null;
let index = arguments[3]??null;
for (var key in options) {
keys.push(key);
values.push(`'${options[key]}'`);
@@ -236,13 +236,13 @@ class Model {
name: config.name,
sql: sql,
success(e) {
if (index) {
if(index){
callback(null, e, options, index);
}
callback(null, e, options);
},
fail(e) {
if (index) {
if(index){
callback(e, null, options, index);
}
callback(e, null, options);
@@ -256,7 +256,7 @@ class Model {
/**
* @description 更新数据
* @param {Object} options可选参数 更新条件
* @param {Object} obj 修改后的数据
* @param {Object} obj 修改后的数据
* @param {Function} callback :err,results=>{}
*/
update(options, obj, callback) {
@@ -332,7 +332,7 @@ class Model {
* @description 重命名或者新增列
* @param {Object} options 参数 数组为新增多列 对象为新增单列{aa} 字符串重命名
* @param {Function} callback :err,results=>{}
* @return:
* @return:
*/
alter(options, callback) {
let self = this;
@@ -366,11 +366,11 @@ class Model {
return this;
}
/**
* @description
* @description
* @param {Model} model 右 Model
* @param {Object} options
* @param {Function} callback
* @returns
* @param {Object} options
* @param {Function} callback
* @returns
*/
join(model, options, callback) {
if (!model) {
@@ -445,8 +445,8 @@ class Model {
}
/**
* @description 判断是否存在
* @param {Function} callback
* @description 判断是否存在
* @param {Function} callback
*/
isExist(callback) {
let sql = `SELECT count(*) AS isExist FROM sqlite_master WHERE type='table' AND name='${this.name}'`;
@@ -467,7 +467,7 @@ class Model {
}
/**
* @description 删除数据表 **不推荐**
* @param {Function} callback
* @param {Function} callback
*/
drop(callback) {
var sql = `DROP TABLE '${this.name}'`;
@@ -490,7 +490,7 @@ class Model {
/**
* @description 创建数据表 **不推荐**
* @param {Function} callback
* @param {Function} callback
*/
create(callback) {
let self = this;
@@ -528,7 +528,7 @@ class Model {
});
}
// TODO 更新表结构
// TODO 数据表备份??
// TODO 数据表备份??
// TODO 多表联查
// TODO 下班了其他的想不起来 回头再说
}
@@ -542,7 +542,7 @@ export class usqlite {
* {name: 'demo', path: '_doc/demo.db'}
* - name 数据库名称*
* - path 数据库路径
* @param {Function} callback
* @param {Function} callback
*/
constructor(options, callback) {
console.warn('No instantiation');
@@ -553,7 +553,7 @@ export class usqlite {
* {name: 'demo', path: '_doc/demo.db'}
* - name 数据库名称*
* - path 数据库路径
* @param {Function} callback
* @param {Function} callback
*/
static connect(options, callback) {
config.name = options.name; // 数据库名称*
@@ -576,7 +576,7 @@ export class usqlite {
}
/**
* @description 断开数据库
* @param {*} callback
* @param {*} callback
*/
static close(callback) {
plus.sqlite.closeDatabase({