fix in passing originEntity from frontend to backend, some refactorings

This commit is contained in:
azivner
2018-08-16 23:00:04 +02:00
parent 385d97a9b3
commit 208771216e
14 changed files with 36 additions and 24 deletions

View File

@@ -17,7 +17,7 @@ const Option = require('../entities/option');
async function getHash(entityConstructor, whereBranch) {
// subselect is necessary to have correct ordering in GROUP_CONCAT
const query = `SELECT GROUP_CONCAT(hash) FROM (SELECT hash FROM ${entityConstructor.tableName} `
const query = `SELECT GROUP_CONCAT(hash) FROM (SELECT hash FROM ${entityConstructor.entityName} `
+ (whereBranch ? `WHERE ${whereBranch} ` : '') + `ORDER BY ${entityConstructor.primaryKeyName})`;
let contentToHash = await sql.getValue(query);

View File

@@ -15,9 +15,9 @@ async function getEntityFromName(entityName, entityId) {
return null;
}
const constructor = entityConstructor.getEntityFromTableName(entityName);
const constructor = entityConstructor.getEntityFromEntityName(entityName);
return await getEntity(`SELECT * FROM ${constructor.tableName} WHERE ${constructor.primaryKeyName} = ?`, [entityId]);
return await getEntity(`SELECT * FROM ${constructor.entityName} WHERE ${constructor.primaryKeyName} = ?`, [entityId]);
}
async function getEntities(query, params = []) {
@@ -57,7 +57,7 @@ async function getOption(name) {
}
async function updateEntity(entity) {
const entityName = entity.constructor.tableName;
const entityName = entity.constructor.entityName;
const primaryKeyName = entity.constructor.primaryKeyName;
const isNewEntity = !entity[primaryKeyName];