You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -18,10 +18,20 @@ For an example of the parser, check out the [example application](https://pausti
18
18
19
19
### Available functions
20
20
1.`parseQuery(soqlQueryString, options)`
21
-
2.`composeQuery(SoqlQuery, options)`
21
+
2.`isQueryValid(SoqlQuery, options)`
22
+
3.`composeQuery(SoqlQuery, options)`
22
23
23
-
### Parse
24
+
### Parse Query
24
25
The parser takes a SOQL query and returns structured data.
26
+
27
+
Options:
28
+
```typescript
29
+
exportinterfaceSoqlQueryConfig {
30
+
continueIfErrors?:boolean; // default=false
31
+
logging:boolean; // default=false
32
+
}
33
+
```
34
+
25
35
#### Typescript / ES6
26
36
```typescript
27
37
import { parseQuery } from'soql-parser-js';
@@ -83,9 +93,50 @@ This yields an object with the following structure:
83
93
}
84
94
}
85
95
```
86
-
### compose
96
+
### Check if Query is Valid
97
+
This will parse the AST tree to confirm the syntax is valid, but will not parse the tree into a data structure.
98
+
This method is faster than parsing the full query.
99
+
100
+
Options:
101
+
```typescript
102
+
exportinterfaceConfigBase {
103
+
logging:boolean; // default=false
104
+
}
105
+
```
106
+
107
+
```typescript
108
+
import { isQueryValid } from'soql-parser-js';
109
+
110
+
const soql ='SELECT UserId, COUNT(Id) from LoginHistory WHERE LoginTime > 2010-09-20T22:16:30.000Z AND LoginTime < 2010-09-21T22:16:30.000Z GROUP BY UserId';
111
+
112
+
const isValid =isQueryValid(soql);
113
+
114
+
console.log('isValid', isValid);
115
+
116
+
```
117
+
118
+
#### Node
119
+
```javascript
120
+
var soqlParserJs =require('soql-parser-js');
121
+
122
+
constsoql='SELECT UserId, COUNT(Id) from LoginHistory WHERE LoginTime > 2010-09-20T22:16:30.000Z AND LoginTime < 2010-09-21T22:16:30.000Z GROUP BY UserId';
123
+
124
+
constisValid=isQueryValid(soql);
125
+
126
+
console.log('isValid', isValid);
127
+
```
128
+
129
+
### Compose Query
87
130
Composing a query turns a parsed query back into a SOQL query. For some operators, they may be converted to upper case (e.x. NOT, AND)
SELECT Id, Name FROM Account WHERE Id IN (SELECT AccountId FROM Contact WHERE LastName LIKE 'apple%') AND Id IN (SELECT AccountId FROM Opportunity WHERE isClosed = false)
5
-
`;
3
+
// const query = `
4
+
// SELECT Id, Name FROM Account WHERE Id IN (SELECT AccountId FROM Contact WHERE LastName LIKE 'apple%') AND Id IN (SELECT AccountId FROM Opportunity WHERE isClosed = false)
// SELECT Id, Name FROM Account WHERE Id IN (SELECT AccountId FROM Opportunity WHERE StageName = 'Closed Lost')
14
14
// SELECT Id FROM Account WHERE Id NOT IN (SELECT AccountId FROM Opportunity WHERE IsClosed = false)
15
15
// SELECT Id, Name FROM Account WHERE Id IN (SELECT AccountId FROM Contact WHERE LastName LIKE 'apple%') AND Id IN (SELECT AccountId FROM Opportunity WHERE isClosed = false)
16
+
17
+
constquery=`
18
+
SELECT Id, Name FROM Account WHERE Id IN (SELECT AccountId FROM Contact WHERE LastName LIKE 'apple%') AND Id IN (SELECT AccountId FROM Opportunity WHERE isClosed = false)
0 commit comments