# Discovery

The [discovery features of WireBootstrap data sources](https://docs.wirebootstrap.com/wirebootstrap/connecting-to-data/discovery) allow a data service to tell consumes about what information the data service can supply.

Discovery calls to Salesforce in WireBootstrap for meta data use the `object` resource of the REST API.  For details on this resource, visit [Working with Meta Data](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/using_resources_working_with_object_metadata.htm).

## Objects

Use the `discoverEntitiesAsync` method on a data source to get a list of objects (entities) in Salesforce.

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

const tblEntities = await.source.discoverEntitiesAsync();
```

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

```javascript
...

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

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

```

To filter the call to a single object, use the optional configuration parameter setting the `entity` property to the name of the object.

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

const tblEntities = await.source.discoverEntitiesAsync({
    entity: "Account"
});
```

## Fields

Use the `discoverFieldsAsync` method on a data source to get a list of fields for an object in Salesforce.  Pass the name of the entity in the `entity` property of the configuration parameter.

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

const tblFields = await.source.discoverFieldsAsync({
    entity: "Account"
});
```

## Results

The datatable returned from discover calls 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 call to Salesforce.

```javascript
...
const tblEntities = await.source.discoverEntitiesAsync();

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).
