SOQL Parser JS
Status
- This project is a work in progress and is considered an alpha
- The goal of this project is to produce an npm module that will allow import into node projects (and ideally into the browser as well, but this is lower priority because of the size of the code required)
Description
SOQL Parser JS will parse a SOQL query string into an object that is easy to work with and has the query broken down into usable parts.
TODO
Future Idea List - phase 2+
Examples
(This is still a work in progress and will change once the npm bundle structure is figured out)
These examples only work when working with the codebase directly for now until we have an npm module published.
This assumes you are working directly in the app folder.
See ./src/tests/TestCases.ts
for example queries and their generated output.
You can also run any example withing the examples folder to observe the output.
import { parseQuery } from './SoqlParser';
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';
const soqlQuery = parseQuery(soql);
console.log(JSON.stringify(soqlQuery, null, 2));
This yields an object with the following structure:
{
"fields": [
{
"text": "UserId"
},
{
"fn": {
"text": "COUNT(Id)",
"name": "COUNT",
"parameter": "Id"
}
}
],
"subqueries": [],
"sObject": "LoginHistory",
"whereClause": {
"left": {
"field": "LoginTime",
"operator": ">",
"value": "2010-09-20T22:16:30.000Z"
},
"operator": "AND",
"right": {
"left": {
"field": "LoginTime",
"operator": "<",
"value": "2010-09-21T22:16:30.000Z"
}
}
},
"groupBy": {
"field": "UserId"
}
}
Special Thanks