Skip to content

lucasmaciel1996/salesforce-query-builder

Repository files navigation

SalesForce Query Builder

Installation

    npm i salesforce-query-builder

Lib

Simple example of QueryBuilder:

    new SFQuery('Contact')
        .select(['Id', 'Name'])
        .where("Name != null")
        .whereIn('Name', ['Maria', 'Ana'])
        .limit(3)
        .build()

    SELECT
        Id,
        Name
    FROM Contact
        WHERE Name != null AND Name IN ('Maria','Ana')
    LIMIT 3


    new SFQuery('Contact')
        .select([ 'Name'])
        .groupBy("Name")
        .build()

    SELECT
        Name
    FROM Contact
    GROUP BY Name


    new SFQuery('Contact')
        .select([ 'Name'])
        .offset(10)
        .limit(20)
        .build()

    SELECT
        Name
    FROM Contact
    OFFSET 10 LIMIT 20

Relationship example of QueryBuilder:

    new SFQuery('Contact')
        .select(['Id', 'Name','Account__r.Name'])
        .where("Name != null")
        .whereIn('Name', ['Maria', 'Ana'])
        .orderBy('Name', 'DESC')
        .limit(3)
        .build()

    SELECT
        Id,
        Name,
        Account__r.Name
    FROM Contact
        WHERE Name != null AND Name IN ('Maria','Ana')
    ORDER BY Name DESC
    LIMIT 3

EncodeQueryUrl example of QueryBuilder:

encodeQueryUrl(
  new SFQuery("Contact")
    .select(["Id", "Name"])
    .where("Name != null")
    .limit(3)
    .build()
);

("query/?q=SELECT+Id,Name+FROM+Contact+WHERE+Name+!=+null+LIMIT+3");

References

About

QueryBuilder- (soql)(@salesforce)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published