masterrecord 0.0.22 → 0.0.24

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.
@@ -1,442 +1,442 @@
1
- // create a queryModel
2
-
3
- // dateRange = to and from - BETWEEN predicate
4
-
5
- // Operators = NotDefined, Equals, NotEquals, Like, NotLike, In, NotIn
6
-
7
- // LogicalOperator = NotDefined, Or, And, contains, like
8
-
9
- // Conditions = joins, and all other predicates
10
-
11
- // limits - single(), toList()
12
-
13
- // TODO: Turning off lazy loading for specific navigation propertie
14
-
15
- // Rules
16
- // nothing comes after select statment
17
- // where must have a an argument
18
-
19
- // single() method adds limit
20
-
21
-
22
- // TODO: build out conditions
23
- var LogicalQuery = require('masterrecord/QueryLanguage/_LogicalQuery');
24
-
25
-
26
- class QueryModel {
27
-
28
- constructor(model, context){
29
- this.__model = model;
30
- this.__context = context;
31
- this.tokenList = null;
32
- this.firstToken = null;
33
- this.secondToken = null;
34
- this.thirdToken = null;
35
- this.buildQueryList = [];
36
- this.queryModel = {
37
- name : model.__name,
38
- context : null,
39
- limits:{},
40
- conditions : [],
41
- relationships: [],
42
- selects:[]
43
- };
44
- }
45
-
46
- updateQueryName(name){
47
- this.queryModel.name = name;
48
- }
49
-
50
- stringArrayList(addArray, list)
51
- {
52
- var listArray = list.split(',');
53
- for (var i = 0; i < listArray.length; i++) {
54
- addArray.push(listArray[i]);
55
- }
56
- }
57
-
58
- discardToken(){
59
- this.firstToken = this.secondToken;
60
- this.secondToken = this.thirdToken;
61
- if(this.tokenList.length !== 0){
62
- this.thirdToken = this.tokenList.shift();
63
- }
64
- else{
65
- this.thirdToken = "";
66
- }
67
- }
68
-
69
- setupTokenList(){
70
- this.firstToken = this.tokenList.shift();
71
- this.secondToken = this.tokenList.shift();
72
- this.thirdToken = this.tokenList.shift();
73
- }
74
-
75
- condition(tokenList, type){
76
- // update the condition part of the query
77
- this.tokenList = tokenList;
78
- this.setupTokenList();
79
- this.createNewCondition(type);
80
- return this.queryModel;
81
- }
82
-
83
- select(tokenList){
84
-
85
- //this.currentContext = currentContext;
86
- this.tokenList = tokenList;
87
- this.setupTokenList();
88
- this.createNewSelect();
89
- return this.queryModel;
90
- }
91
-
92
- relationship(name, innerQuery){
93
-
94
- var relationshipContext = this.getValidContext(this.__context.__allContexts, name);
95
- // this means it found the context
96
- if(relationshipContext !== -1){
97
- this.discardToken();
98
- var Query = require('masterrecord/QueryLanguage/_simpleQuery');
99
- var queryNew = new Query(relationshipContext, this.__context);
100
- var innerQuery = innerQuery === undefined ? this.buildInnerQueryObject("",queryNew) : innerQuery;
101
- // get all the code that relates to relationship
102
- var relationshipQuery = this.callInnerQuery(innerQuery, queryNew);
103
- this.queryModel.relationships.push(relationshipQuery);
104
- }
105
- //var innerQuery = LQ.build(`s.Fruits.where(r => r.name == "richard").single().flys.distinct().toList()`);
106
- }
107
-
108
- callInnerQuery(innerProp, queryObj){
109
- // TODO: loop through innerprop
110
- var queryHolder = null;
111
-
112
- for (var i = 0; i < innerProp.length; i++) {
113
-
114
- if(innerProp[i].type === "method"){
115
- queryHolder = queryObj[innerProp[i].name](innerProp[i].innerValue);
116
- }
117
- else{
118
- // TODO: we need to turn this back into a string because the data is currupted.
119
- innerProp = innerProp.splice(i, innerProp.length);
120
- this.relationship(innerProp[0].name, innerProp);
121
- }
122
- }
123
-
124
- return queryHolder.__queryModel.queryModel;
125
- }
126
-
127
- buildInnerQueryObject(skip, queryObj){
128
-
129
- skip = skip === undefined ? false : skip;
130
- if(skip){
131
- this.discardToken();
132
- };
133
-
134
- var obj = {
135
- name : null,
136
- type: null,
137
- innerValue : null
138
- }
139
-
140
- if(this.firstToken[0] === "closeBraces"){
141
- this.discardToken();
142
- return this.buildQueryList;
143
- }
144
- else if(this.firstToken[0] === "comma"){
145
- this.discardToken();
146
- return this.buildQueryList;
147
- }
148
- else{
149
- if(this.firstToken[0] === "dot"){
150
- this.discardToken();
151
- this.buildInnerQueryObject(undefined, queryObj);
152
- }
153
- else{
154
- obj.name = this.firstToken[1];
155
- if(this.secondToken[0] === "openParenthesis"){
156
- obj.type = "method";
157
- obj.innerValue = this.getValueInsideParenthesis();
158
- this.buildQueryList.push(obj);
159
- this.buildInnerQueryObject(true, queryObj);
160
- }else{
161
- if(this.firstToken[0] === "field" && this.secondToken[0] === "dot"){
162
- if(queryObj.__queryModel.queryModel.name !== this.firstToken[1]){
163
- obj.type = "relationship";
164
- this.buildQueryList.push(obj);
165
- this.buildInnerQueryObject(true, queryObj);
166
- }else{
167
- this.buildInnerQueryObject(true, queryObj);
168
- }
169
- }else{
170
- this.buildInnerQueryObject(true, queryObj);
171
- }
172
- }
173
- }
174
- }
175
- //this.buildInnerQueryObject();
176
- return this.buildQueryList;
177
- }
178
-
179
- getValueInsideParenthesis(){
180
- var inner = [];
181
- this.discardToken();
182
- while (this.firstToken[0] !== "closeParenthesis"){
183
- inner.push(this.firstToken[1]);
184
- this.discardToken();
185
- }
186
- return inner.join(" ");
187
- // TODO: LOOP through and get all values inside paranthese
188
- }
189
-
190
- // loops through and checks if there is a field inside the context with that name.
191
- getValidContext(contextArray, name){
192
- for (var i = 0; i < contextArray.length; i++) {
193
- if(contextArray[i].__name === name){
194
- return contextArray[i];
195
- }
196
- }
197
- return -1;
198
- }
199
-
200
- limit(){
201
- // update the limit part of the query
202
- }
203
-
204
- dateRange(){
205
- // update ht edate range of the query
206
- }
207
-
208
- checkComplete(val, skip){
209
- skip = skip === undefined ? false : skip;
210
- if(skip){
211
- this.discardToken();
212
- };
213
-
214
- var switchValue = this.firstToken[0] + " " + this.secondToken[0] + " " + this.thirdToken[0];
215
-
216
- switch(switchValue) {
217
- case "field dot field":
218
- this.addFieldName(val);
219
- break;
220
- case "not field dot":
221
- // this.addNotFieldNot(); TODO : implement
222
- break;
223
- case "comma field colon":
224
- this.createNewSelect(true);
225
- break;
226
- case "field arrowHead openParenthesis":
227
- this.getContextName(val);
228
- break;
229
- case "field arrowHead field":
230
- this.getContextName(val);
231
- break;
232
- case "field colon not":
233
- this.getReturnName(val);
234
- break;
235
- case "field colon field":
236
- this.getReturnName(val);
237
- break;
238
- case "dot field openParenthesis":
239
- this.checkConditions();
240
- break;
241
- case "dot field dot":
242
- this.addFieldName(val);
243
- break;
244
- case undefined:
245
- return;
246
- break;
247
- case 'undefined undefined undefined':
248
- return;
249
- break
250
- default:
251
- // code block
252
- this.checkComplete(val, true);
253
- }
254
-
255
- return;
256
- }
257
-
258
- createNewCondition(type){
259
-
260
- this.currentCondition = {
261
- type : type,
262
- context: "",
263
- field : {},
264
- operators : [],
265
- };
266
-
267
- this.queryModel.conditions.push(this.currentCondition);
268
- this.checkComplete(this.currentCondition);
269
- return;
270
- }
271
-
272
- createNewSelect(option){
273
-
274
- this.currentSelect = {
275
- returnName : "",
276
- context: "",
277
- field : {},
278
- operators : [],
279
- };
280
-
281
- this.queryModel.selects.push(this.currentSelect);
282
- this.checkComplete(this.currentSelect, option);
283
- return;
284
- }
285
-
286
- getContextName(val){
287
- this.queryModel.context = this.firstToken[1];
288
- this.checkComplete(val, true);
289
- return;
290
- }
291
-
292
- getReturnName(prop){
293
- prop.returnName = this.firstToken[1];
294
- this.checkComplete(prop, true);
295
- return;
296
- }
297
-
298
- addFieldName(val){
299
- // loop through all the context to see if there is one with that name
300
- // and if so then thats a relationship
301
- if(this.__model[this.thirdToken[1]] !== undefined) //for testing purposes this will be a relationship
302
- {
303
- if(this.getValidContext(this.__context.__allContexts, this.thirdToken[1]) !== -1){
304
- this.relationship(this.thirdToken[1]);
305
- }
306
- else{
307
- if(val.field.context === undefined){
308
- val.field.context = this.firstToken[1];
309
- val.field.parent = this.queryModel.context;
310
- val.field.name = this.thirdToken[1];
311
- }
312
- }
313
-
314
- }
315
- this.checkOperators(val);
316
- this.checkComplete(val, true);
317
- return;
318
- }
319
-
320
- checkConditions(){
321
- switch(this.secondToken[0] + " " + this.thirdToken[0]) {
322
- case "in openParenthesis":
323
- this.parseInCondition();
324
- this.checkSectionComplete(this.firstToken[0]);
325
- break;
326
- case "like openParenthesis":
327
- this.parseInCondition();
328
- break;
329
- case "single openParenthesis":
330
- this.parseSingleCondition();
331
- break;
332
- case "where openParenthesis":
333
- this.parseWhereCondition();
334
- break;
335
- }
336
- this.checkComplete();
337
- return;
338
- }
339
-
340
- checkOperators(val){
341
-
342
- this.discardToken();
343
- this.discardToken();
344
- this.discardToken();
345
-
346
- if(this.isOperator(this.firstToken))
347
- {
348
- this.createCurrentOperator(val.field);
349
- this.checkLogicalOperators();
350
- val.operators.push(this.currentOperator);
351
- }
352
- this.checkComplete(val);
353
- return;
354
- }
355
-
356
- checkLogicalOperators(){
357
- // will add logical operator to the
358
- if(this.isLogicalOperator(this.firstToken)){
359
- this.currentOperator.logicalOperator = this.firstToken[0];
360
- this.discardToken();
361
- }
362
- }
363
-
364
- isQuotes(token){
365
- return token[0] === "doubleQuotes"
366
- || token[0] === "singleQuotes";
367
- }
368
-
369
- isLogicalOperator(token){
370
- return token[0] === "or"
371
- || token[0] === "and";
372
- }
373
-
374
- isOperator(token)
375
- {
376
- return token[0] === "notEqualsSingle"
377
- || token[0] === "notEqualsDouble"
378
- || token[0] === "tripleEquals"
379
- || token[0] === "doubleEquals"
380
- || token[0] === "greaterThen"
381
- || token[0] === "lessThen"
382
- || token[0] === "greaterThenEqualTo"
383
- || token[0] === "lessThenEqualTo"
384
- || token[0] === "or"
385
- || token[0] === "and";
386
- }
387
-
388
- createCurrentOperator(field)
389
- {
390
- this.currentOperator = {
391
- context : field.name, // field name
392
- operator : this.firstToken[0],
393
- logicalOperator : null
394
- };
395
-
396
- this.discardToken();
397
-
398
- if(this.isQuotes(this.firstToken)){
399
- this.discardToken();
400
- this.currentOperator.value = this.firstToken[1]; // field name
401
- this.discardToken();
402
- }
403
- else{
404
- this.currentOperator.value = this.firstToken[1];
405
- }
406
-
407
- this.discardToken();
408
- }
409
-
410
- parseInCondition(){
411
- this.discardToken();
412
-
413
- this.currentOperator = {
414
- context : this.currentSelect.fields[this.currentSelect.fields.length - 1].name, // field name
415
- operator : this.firstToken[0],
416
- logicalOperator : null
417
- };
418
-
419
- this.discardToken();
420
- this.discardToken();
421
-
422
- if(this.isQuotes(this.firstToken)){
423
- this.discardToken();
424
- this.currentOperator.value = this.firstToken[1]; // field name
425
- this.discardToken();
426
- }
427
- else{
428
- this.currentOperator.value = this.firstToken[1];
429
- }
430
- this.currentSelect.operators.push(this.currentOperator);
431
- this.discardToken();
432
- this.discardToken();
433
- }
434
-
435
- parseWhereCondition(){
436
-
437
- // create new condition and with name where
438
- }
439
- }
440
-
441
-
1
+ // create a queryModel
2
+
3
+ // dateRange = to and from - BETWEEN predicate
4
+
5
+ // Operators = NotDefined, Equals, NotEquals, Like, NotLike, In, NotIn
6
+
7
+ // LogicalOperator = NotDefined, Or, And, contains, like
8
+
9
+ // Conditions = joins, and all other predicates
10
+
11
+ // limits - single(), toList()
12
+
13
+ // TODO: Turning off lazy loading for specific navigation propertie
14
+
15
+ // Rules
16
+ // nothing comes after select statment
17
+ // where must have a an argument
18
+
19
+ // single() method adds limit
20
+
21
+
22
+ // TODO: build out conditions
23
+ var LogicalQuery = require('masterrecord/QueryLanguage/_LogicalQuery');
24
+
25
+
26
+ class QueryModel {
27
+
28
+ constructor(model, context){
29
+ this.__model = model;
30
+ this.__context = context;
31
+ this.tokenList = null;
32
+ this.firstToken = null;
33
+ this.secondToken = null;
34
+ this.thirdToken = null;
35
+ this.buildQueryList = [];
36
+ this.queryModel = {
37
+ name : model.__name,
38
+ context : null,
39
+ limits:{},
40
+ conditions : [],
41
+ relationships: [],
42
+ selects:[]
43
+ };
44
+ }
45
+
46
+ updateQueryName(name){
47
+ this.queryModel.name = name;
48
+ }
49
+
50
+ stringArrayList(addArray, list)
51
+ {
52
+ var listArray = list.split(',');
53
+ for (var i = 0; i < listArray.length; i++) {
54
+ addArray.push(listArray[i]);
55
+ }
56
+ }
57
+
58
+ discardToken(){
59
+ this.firstToken = this.secondToken;
60
+ this.secondToken = this.thirdToken;
61
+ if(this.tokenList.length !== 0){
62
+ this.thirdToken = this.tokenList.shift();
63
+ }
64
+ else{
65
+ this.thirdToken = "";
66
+ }
67
+ }
68
+
69
+ setupTokenList(){
70
+ this.firstToken = this.tokenList.shift();
71
+ this.secondToken = this.tokenList.shift();
72
+ this.thirdToken = this.tokenList.shift();
73
+ }
74
+
75
+ condition(tokenList, type){
76
+ // update the condition part of the query
77
+ this.tokenList = tokenList;
78
+ this.setupTokenList();
79
+ this.createNewCondition(type);
80
+ return this.queryModel;
81
+ }
82
+
83
+ select(tokenList){
84
+
85
+ //this.currentContext = currentContext;
86
+ this.tokenList = tokenList;
87
+ this.setupTokenList();
88
+ this.createNewSelect();
89
+ return this.queryModel;
90
+ }
91
+
92
+ relationship(name, innerQuery){
93
+
94
+ var relationshipContext = this.getValidContext(this.__context.__allContexts, name);
95
+ // this means it found the context
96
+ if(relationshipContext !== -1){
97
+ this.discardToken();
98
+ var Query = require('masterrecord/QueryLanguage/_simpleQuery');
99
+ var queryNew = new Query(relationshipContext, this.__context);
100
+ var innerQuery = innerQuery === undefined ? this.buildInnerQueryObject("",queryNew) : innerQuery;
101
+ // get all the code that relates to relationship
102
+ var relationshipQuery = this.callInnerQuery(innerQuery, queryNew);
103
+ this.queryModel.relationships.push(relationshipQuery);
104
+ }
105
+ //var innerQuery = LQ.build(`s.Fruits.where(r => r.name == "richard").single().flys.distinct().toList()`);
106
+ }
107
+
108
+ callInnerQuery(innerProp, queryObj){
109
+ // TODO: loop through innerprop
110
+ var queryHolder = null;
111
+
112
+ for (var i = 0; i < innerProp.length; i++) {
113
+
114
+ if(innerProp[i].type === "method"){
115
+ queryHolder = queryObj[innerProp[i].name](innerProp[i].innerValue);
116
+ }
117
+ else{
118
+ // TODO: we need to turn this back into a string because the data is currupted.
119
+ innerProp = innerProp.splice(i, innerProp.length);
120
+ this.relationship(innerProp[0].name, innerProp);
121
+ }
122
+ }
123
+
124
+ return queryHolder.__queryModel.queryModel;
125
+ }
126
+
127
+ buildInnerQueryObject(skip, queryObj){
128
+
129
+ skip = skip === undefined ? false : skip;
130
+ if(skip){
131
+ this.discardToken();
132
+ };
133
+
134
+ var obj = {
135
+ name : null,
136
+ type: null,
137
+ innerValue : null
138
+ }
139
+
140
+ if(this.firstToken[0] === "closeBraces"){
141
+ this.discardToken();
142
+ return this.buildQueryList;
143
+ }
144
+ else if(this.firstToken[0] === "comma"){
145
+ this.discardToken();
146
+ return this.buildQueryList;
147
+ }
148
+ else{
149
+ if(this.firstToken[0] === "dot"){
150
+ this.discardToken();
151
+ this.buildInnerQueryObject(undefined, queryObj);
152
+ }
153
+ else{
154
+ obj.name = this.firstToken[1];
155
+ if(this.secondToken[0] === "openParenthesis"){
156
+ obj.type = "method";
157
+ obj.innerValue = this.getValueInsideParenthesis();
158
+ this.buildQueryList.push(obj);
159
+ this.buildInnerQueryObject(true, queryObj);
160
+ }else{
161
+ if(this.firstToken[0] === "field" && this.secondToken[0] === "dot"){
162
+ if(queryObj.__queryModel.queryModel.name !== this.firstToken[1]){
163
+ obj.type = "relationship";
164
+ this.buildQueryList.push(obj);
165
+ this.buildInnerQueryObject(true, queryObj);
166
+ }else{
167
+ this.buildInnerQueryObject(true, queryObj);
168
+ }
169
+ }else{
170
+ this.buildInnerQueryObject(true, queryObj);
171
+ }
172
+ }
173
+ }
174
+ }
175
+ //this.buildInnerQueryObject();
176
+ return this.buildQueryList;
177
+ }
178
+
179
+ getValueInsideParenthesis(){
180
+ var inner = [];
181
+ this.discardToken();
182
+ while (this.firstToken[0] !== "closeParenthesis"){
183
+ inner.push(this.firstToken[1]);
184
+ this.discardToken();
185
+ }
186
+ return inner.join(" ");
187
+ // TODO: LOOP through and get all values inside paranthese
188
+ }
189
+
190
+ // loops through and checks if there is a field inside the context with that name.
191
+ getValidContext(contextArray, name){
192
+ for (var i = 0; i < contextArray.length; i++) {
193
+ if(contextArray[i].__name === name){
194
+ return contextArray[i];
195
+ }
196
+ }
197
+ return -1;
198
+ }
199
+
200
+ limit(){
201
+ // update the limit part of the query
202
+ }
203
+
204
+ dateRange(){
205
+ // update ht edate range of the query
206
+ }
207
+
208
+ checkComplete(val, skip){
209
+ skip = skip === undefined ? false : skip;
210
+ if(skip){
211
+ this.discardToken();
212
+ };
213
+
214
+ var switchValue = this.firstToken[0] + " " + this.secondToken[0] + " " + this.thirdToken[0];
215
+
216
+ switch(switchValue) {
217
+ case "field dot field":
218
+ this.addFieldName(val);
219
+ break;
220
+ case "not field dot":
221
+ // this.addNotFieldNot(); TODO : implement
222
+ break;
223
+ case "comma field colon":
224
+ this.createNewSelect(true);
225
+ break;
226
+ case "field arrowHead openParenthesis":
227
+ this.getContextName(val);
228
+ break;
229
+ case "field arrowHead field":
230
+ this.getContextName(val);
231
+ break;
232
+ case "field colon not":
233
+ this.getReturnName(val);
234
+ break;
235
+ case "field colon field":
236
+ this.getReturnName(val);
237
+ break;
238
+ case "dot field openParenthesis":
239
+ this.checkConditions();
240
+ break;
241
+ case "dot field dot":
242
+ this.addFieldName(val);
243
+ break;
244
+ case undefined:
245
+ return;
246
+ break;
247
+ case 'undefined undefined undefined':
248
+ return;
249
+ break
250
+ default:
251
+ // code block
252
+ this.checkComplete(val, true);
253
+ }
254
+
255
+ return;
256
+ }
257
+
258
+ createNewCondition(type){
259
+
260
+ this.currentCondition = {
261
+ type : type,
262
+ context: "",
263
+ field : {},
264
+ operators : [],
265
+ };
266
+
267
+ this.queryModel.conditions.push(this.currentCondition);
268
+ this.checkComplete(this.currentCondition);
269
+ return;
270
+ }
271
+
272
+ createNewSelect(option){
273
+
274
+ this.currentSelect = {
275
+ returnName : "",
276
+ context: "",
277
+ field : {},
278
+ operators : [],
279
+ };
280
+
281
+ this.queryModel.selects.push(this.currentSelect);
282
+ this.checkComplete(this.currentSelect, option);
283
+ return;
284
+ }
285
+
286
+ getContextName(val){
287
+ this.queryModel.context = this.firstToken[1];
288
+ this.checkComplete(val, true);
289
+ return;
290
+ }
291
+
292
+ getReturnName(prop){
293
+ prop.returnName = this.firstToken[1];
294
+ this.checkComplete(prop, true);
295
+ return;
296
+ }
297
+
298
+ addFieldName(val){
299
+ // loop through all the context to see if there is one with that name
300
+ // and if so then thats a relationship
301
+ if(this.__model[this.thirdToken[1]] !== undefined) //for testing purposes this will be a relationship
302
+ {
303
+ if(this.getValidContext(this.__context.__allContexts, this.thirdToken[1]) !== -1){
304
+ this.relationship(this.thirdToken[1]);
305
+ }
306
+ else{
307
+ if(val.field.context === undefined){
308
+ val.field.context = this.firstToken[1];
309
+ val.field.parent = this.queryModel.context;
310
+ val.field.name = this.thirdToken[1];
311
+ }
312
+ }
313
+
314
+ }
315
+ this.checkOperators(val);
316
+ this.checkComplete(val, true);
317
+ return;
318
+ }
319
+
320
+ checkConditions(){
321
+ switch(this.secondToken[0] + " " + this.thirdToken[0]) {
322
+ case "in openParenthesis":
323
+ this.parseInCondition();
324
+ this.checkSectionComplete(this.firstToken[0]);
325
+ break;
326
+ case "like openParenthesis":
327
+ this.parseInCondition();
328
+ break;
329
+ case "single openParenthesis":
330
+ this.parseSingleCondition();
331
+ break;
332
+ case "where openParenthesis":
333
+ this.parseWhereCondition();
334
+ break;
335
+ }
336
+ this.checkComplete();
337
+ return;
338
+ }
339
+
340
+ checkOperators(val){
341
+
342
+ this.discardToken();
343
+ this.discardToken();
344
+ this.discardToken();
345
+
346
+ if(this.isOperator(this.firstToken))
347
+ {
348
+ this.createCurrentOperator(val.field);
349
+ this.checkLogicalOperators();
350
+ val.operators.push(this.currentOperator);
351
+ }
352
+ this.checkComplete(val);
353
+ return;
354
+ }
355
+
356
+ checkLogicalOperators(){
357
+ // will add logical operator to the
358
+ if(this.isLogicalOperator(this.firstToken)){
359
+ this.currentOperator.logicalOperator = this.firstToken[0];
360
+ this.discardToken();
361
+ }
362
+ }
363
+
364
+ isQuotes(token){
365
+ return token[0] === "doubleQuotes"
366
+ || token[0] === "singleQuotes";
367
+ }
368
+
369
+ isLogicalOperator(token){
370
+ return token[0] === "or"
371
+ || token[0] === "and";
372
+ }
373
+
374
+ isOperator(token)
375
+ {
376
+ return token[0] === "notEqualsSingle"
377
+ || token[0] === "notEqualsDouble"
378
+ || token[0] === "tripleEquals"
379
+ || token[0] === "doubleEquals"
380
+ || token[0] === "greaterThen"
381
+ || token[0] === "lessThen"
382
+ || token[0] === "greaterThenEqualTo"
383
+ || token[0] === "lessThenEqualTo"
384
+ || token[0] === "or"
385
+ || token[0] === "and";
386
+ }
387
+
388
+ createCurrentOperator(field)
389
+ {
390
+ this.currentOperator = {
391
+ context : field.name, // field name
392
+ operator : this.firstToken[0],
393
+ logicalOperator : null
394
+ };
395
+
396
+ this.discardToken();
397
+
398
+ if(this.isQuotes(this.firstToken)){
399
+ this.discardToken();
400
+ this.currentOperator.value = this.firstToken[1]; // field name
401
+ this.discardToken();
402
+ }
403
+ else{
404
+ this.currentOperator.value = this.firstToken[1];
405
+ }
406
+
407
+ this.discardToken();
408
+ }
409
+
410
+ parseInCondition(){
411
+ this.discardToken();
412
+
413
+ this.currentOperator = {
414
+ context : this.currentSelect.fields[this.currentSelect.fields.length - 1].name, // field name
415
+ operator : this.firstToken[0],
416
+ logicalOperator : null
417
+ };
418
+
419
+ this.discardToken();
420
+ this.discardToken();
421
+
422
+ if(this.isQuotes(this.firstToken)){
423
+ this.discardToken();
424
+ this.currentOperator.value = this.firstToken[1]; // field name
425
+ this.discardToken();
426
+ }
427
+ else{
428
+ this.currentOperator.value = this.firstToken[1];
429
+ }
430
+ this.currentSelect.operators.push(this.currentOperator);
431
+ this.discardToken();
432
+ this.discardToken();
433
+ }
434
+
435
+ parseWhereCondition(){
436
+
437
+ // create new condition and with name where
438
+ }
439
+ }
440
+
441
+
442
442
  module.exports = QueryModel;