> For the complete documentation index, see [llms.txt](https://docs.wirebootstrap.com/salesforce/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wirebootstrap.com/salesforce/queries.md).

# Queries

Salesforce queries in WireBootstrap use the `query` resource of the REST API to execute *SOQL* in Salesforce.  For details on this resource, visit [Execute a SOQL Query](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm).

## Creating Queries

To create a query against Salesforce in WireBootstrap, use the [standard table query interface in WireBootstrap](https://docs.wirebootstrap.com/wirebootstrap/creating-queries/select-queries). &#x20;

For example, to request a list of account records, use the `Account` entity.

```javascript
const query = wire.data.select().from("Account");
```

To filter the accounts returned, use the `where` method with a filter expression method.

```javascript
const query = wire.data.select().from("Account")
    .where().eq("Active__c", "Yes");
```

The `where` method also takes an optional string parameter to create custom filters.

```javascript
const query = wire.data.select().from("Account")
    .where("Name LIKE 'United*'");
```

## Execute Queries

After creating a query, execute the query in Salesforce using the `execAsync` method on the [data source](/salesforce/data-connector.md#data-source).

```javascript
const source = new wire.data.DataSource("sf", {
    ...
});

const tblAccounts = await source.execAsync(query);
```

Query results are returned in a [WireBootstrap DataTable](https://docs.wirebootstrap.com/wirebootstrap/working-with-datatables/datatables) object. &#x20;

```javascript
...

const tblAccounts = await.source.execAsync(query);

// grab an array of the first 10 account objects ordered by account name
const rows = tblAccounts.select().top(10).orderBy("Name").rows();

```

## Results

The datatable returned from the query contains the list of records requested from Salesforce.  However, the response returned from Salesforce contains much more data than can be represented in a WireBootstrap datatable. &#x20;

The [service provider](https://docs.wirebootstrap.com/wirebootstrap/connecting-to-data/data-connectors#service-providers) for the WireBootstrap for Salesforce Data Connector has an extension method called `results` which will return the raw results from the last Salesforce query.

```javascript
...
const tblAccounts = await.source.execAsync(query);

const results = source.serviceProvider().results();
```

For more on service provider extensions methods, visit [Provider Extensions](https://docs.wirebootstrap.com/wirebootstrap/connecting-to-data/data-connectors#provider-extensions).
