This repository was archived by the owner on Apr 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathQueryBuilder.js
More file actions
55 lines (53 loc) · 1.9 KB
/
QueryBuilder.js
File metadata and controls
55 lines (53 loc) · 1.9 KB
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
52
53
54
55
import $data, { $C, Guard, Container, Exception } from '../TypeSystem/index.js';
$C('$data.queryBuilder', null, null, {
constructor: function () {
this._fragments = {};
this.selectedFragment = null;
this._binderConfig = {};
this.modelBinderConfig = this._binderConfig;
this._binderConfigPropertyStack = [];
},
selectTextPart: function (name) {
if (!this._fragments[name]) {
this._fragments[name] = { text: '', params: [] };
}
this.selectedFragment = this._fragments[name];
},
getTextPart: function (name) {
return this._fragments[name];
},
addText: function (textParticle) {
this.selectedFragment.text += textParticle;
},
addParameter: function (param) {
this.selectedFragment.params.push(param);
},
selectModelBinderProperty: function (name) {
this._binderConfigPropertyStack.push(this.modelBinderConfig);
if (!(name in this.modelBinderConfig)) {
this.modelBinderConfig[name] = {};
}
this.modelBinderConfig = this.modelBinderConfig[name];
},
popModelBinderProperty: function () {
if (this._binderConfigPropertyStack.length === 0) {
this.modelBinderConfig = this._binderConfig();
} else {
this.modelBinderConfig = this._binderConfigPropertyStack.pop();
}
},
resetModelBinderProperty: function (name) {
this._binderConfigPropertyStack = [];
this.modelBinderConfig = this._binderConfig;
},
addKeyField: function (name) {
if(!this.modelBinderConfig['$keys']){
this.modelBinderConfig['$keys'] = new Array();
}
this.modelBinderConfig['$keys'].push(name);
},
stackContainsType: function(elementType) {
return this._binderConfigPropertyStack.map(p => p.$type).indexOf(elementType) >= 0;
},
});
export default $data