# salesforce-query-builder

> QueryBuilder- (soql)(@SalesForce)

Latest version **1.0.2** (published 2024-07-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install salesforce-query-builder
pnpm add salesforce-query-builder
yarn add salesforce-query-builder
bun add salesforce-query-builder
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-07-01 |
| First published | 2024-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Lucas Maciel |
| Keywords | soql, salesforce, compose, parser, query-builder, encode-query |

## Links

- npm: https://www.npmjs.com/package/salesforce-query-builder
- Repository: https://github.com/lucasmaciel1996/salesforce-query-builder
- Homepage: https://github.com/lucasmaciel1996/salesforce-query-builder#readme
- Issues: https://github.com/lucasmaciel1996/salesforce-query-builder/issues
- npm.io page: https://npm.io/package/salesforce-query-builder

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2024-07-01
- 1.0.1 — 2024-05-21
- 1.0.0 — 2024-03-28

## README

## SalesForce Query Builder

## Installation

```bash
    npm i salesforce-query-builder
```
[Lib](https://www.npmjs.com/package/salesforce-query-builder)

### Simple example of QueryBuilder:

```typescript
    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:

```typescript
    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:

```typescript
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

- [SOQL and SOSL Reference on Salesforce Developer](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_sosl_intro.htm)

---
_Source: https://npm.io/package/salesforce-query-builder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
