mm_os 3.1.6 → 3.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/com/db/drive.js +13 -10
- package/package.json +1 -1
package/core/com/db/drive.js
CHANGED
|
@@ -236,7 +236,7 @@ Drive.prototype.model_index = function(o) {
|
|
|
236
236
|
* @param {Object} db 数据库管理器
|
|
237
237
|
* @return {Array} 索引列表
|
|
238
238
|
*/
|
|
239
|
-
Drive.prototype.
|
|
239
|
+
Drive.prototype.update_file_index = function(db) {
|
|
240
240
|
var sql = "SHOW INDEX FROM `" + this.config.table + "`";
|
|
241
241
|
var rows = db.run(sql);
|
|
242
242
|
var dict = {};
|
|
@@ -294,27 +294,31 @@ Drive.prototype.update_file = async function(db, cover) {
|
|
|
294
294
|
list.push(field);
|
|
295
295
|
}
|
|
296
296
|
cg.fields = list;
|
|
297
|
-
cg.index = await this.
|
|
297
|
+
cg.index = await this.update_file_index(db);
|
|
298
298
|
if (!cg.name) {
|
|
299
299
|
cg.name = cg.table;
|
|
300
300
|
}
|
|
301
301
|
await this.update_app(cover);
|
|
302
302
|
};
|
|
303
303
|
|
|
304
|
+
/**
|
|
305
|
+
* @param {Object} db
|
|
306
|
+
*/
|
|
304
307
|
Drive.prototype.update_db_index = async function(db) {
|
|
305
|
-
|
|
308
|
+
var cg = this.config;
|
|
309
|
+
var indexes = cg.indexes;
|
|
306
310
|
// 更新索引
|
|
307
311
|
if (indexes) {
|
|
308
|
-
|
|
309
|
-
|
|
312
|
+
var len = indexes.length;
|
|
313
|
+
for (var i = 0; i < len; i++) {
|
|
314
|
+
var o = indexes[i];
|
|
310
315
|
var sql_start = "";
|
|
311
|
-
if (
|
|
316
|
+
if (o.type === "unique") {
|
|
312
317
|
sql_start = "CREATE UNIQUE INDEX `"
|
|
313
318
|
} else {
|
|
314
319
|
sql_start = "CREATE INDEX `";
|
|
315
320
|
}
|
|
316
|
-
|
|
317
|
-
await db.exec(sql_start + m.name + "` ON `" + table + "` (" + m.fields + ");");
|
|
321
|
+
await db.exec(sql_start + o.name + "` ON `" + table + "` (" + o.fields + ");");
|
|
318
322
|
}
|
|
319
323
|
}
|
|
320
324
|
}
|
|
@@ -465,9 +469,8 @@ Drive.prototype.update_db = async function(db) {
|
|
|
465
469
|
.name) + sql);
|
|
466
470
|
}
|
|
467
471
|
}
|
|
468
|
-
await this.update_db_index(db);
|
|
469
472
|
} else {
|
|
470
|
-
return "
|
|
473
|
+
return "数据表更新失败";
|
|
471
474
|
}
|
|
472
475
|
};
|
|
473
476
|
|