-
Notifications
You must be signed in to change notification settings - Fork 1
/
mysql-update-model.ts
52 lines (46 loc) · 1.92 KB
/
mysql-update-model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { ColumnStore, TableStore, RelationshipStore, PropertyMapStore,
EntityType } from '../../metadata/';
import { From, UpdateType, UpdateModel, MySQLUpdate, MySQLEscaper,
MySQLExecuter } from '../';
/**
* An [[UpdateModel]] class for MySQL.
*/
export class MySQLUpdateModel<T> extends UpdateModel<T> {
/**
* Initialize the query using an Entity type and an Entity instance (a
* model).
* @param colStore - Used for accessing columns in tables.
* @param tblStore - Used for accessing tables in the database.
* @param relStore - Used for accessing relationships between tables.
* @param propStore - Used for pulling table property maps (used in
* conjunction with the relStore to get remote columns).
* @param escaper - A [[MySQLEscaper]] instance. Used when escaping column
* names in compiled conditions.
* @param executer - A [[MySQLExecuter]] instance for executing queries.
* @param Entity - The type of model to update, which is the constructor of a
* [[Table]]-decorated class.
* @param model - An Entity instance to update, which must have the primary
* key set.
*/
constructor(
protected colStore: ColumnStore,
protected tblStore: TableStore,
protected relStore: RelationshipStore,
protected propStore: PropertyMapStore,
protected escaper: MySQLEscaper,
protected executer: MySQLExecuter,
protected Entity: EntityType<T>,
protected model: T) {
super(colStore, tblStore, relStore, propStore, escaper, executer, Entity, model);
}
/**
* Produce a [[MySQLUpdate]] instance using the [[From]] instance and the
* update model created from createUpdateModel.
* @param from - A [[From]] instance, passed to the [[MySQLUpdate]] constructor.
* constructor.
*/
protected produceQuery(from: From): MySQLUpdate {
const updateModel = this.createUpdateModel(from);
return new MySQLUpdate(this.escaper, this.executer, from, updateModel);
}
}