# Local Data

The *WireBootstrap Local Data Connector* is included in the core WireBootstrap framework.  The *WireBootstrap Local Data Connector* allows arrays of objects to be used as a pseudo data service. These local arrays appear to the client framework as data services that can be queried dynamically. This data can also be loaded from remote static JSON or CSV files.

## Provider Key

Use the `local` provider key to use the service provider for this data connector with a data source.

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

## Configuration

| Name | Default | Description                                                                                                 |
| ---- | ------- | ----------------------------------------------------------------------------------------------------------- |
| Data |         | The static data to as the source of data.  See [details](broken://pages/-MM3mJXauaCHwUbArRVY#data) below.   |
| Json |         | The Json data to use as the source of data.  See [details](broken://pages/-MM3mJXauaCHwUbArRVY#json) below. |
| Csv  |         | The CSV data to use as the source of data.  See [details](broken://pages/-MM3mJXauaCHwUbArRVY#csv) below.   |

### Data

To use an object array as a source of data, set the array into the provider `Data` property.

```javascript
const source = new wire.data.DataSource("local", {
    ...
    Provider: {
       Data: [
          { UserName: "jembid", FullName: "Joel Embid" },
          { UserName: "bsimmons", FullName: "Ben Simmons" }
       ]
    }
});
```

### Json

To use a JSON file as a source of data, set the `url` property of the `Json` provider property to the URL of the JSON file.

The example below will load the `sales.json` file to be used as the source of data.

```javascript
const source = new wire.data.DataSource("local", {
    ...
    Provider: {
       Json: { url: "./data/sales.json" }       
    }
});
```

### Csv

To use a CSV file as a source of data, set the `url` property of the `Csv` provider property to the URL of the CSV file.

The example below will load the `sales.csv` file to be used as the source of data.

```javascript
const source = new wire.data.DataSource("local", {
    ...
    Provider: {
       Csv: { url: "./data/sales.csv" }       
    }
});
```

#### Papa

CSV files are read and converted into an array of JavaScript objects using [Papa Parse](https://www.papaparse.com).  This library will be loaded from the following CDN location if the `Papa` object has not already been loaded on the page.

{% embed url="<https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js>" %}

To customize the configuration for Papa Parse for reading in CSV files, use the `papa` provider property.  This property is a pass-through to the [native Papa Parse configuration](https://www.papaparse.com/docs#config).

The example below changes the default field delimiter to a pipe.

```javascript
const source = new wire.data.DataSource("local", {
    ...
    Provider: {
       papa: { delimiter: "|" }       
    }
});
```

## Allow

Service providers are able to tell consumers about the functionality they support through an [`allow`](https://docs.wirebootstrap.com/wirebootstrap/connecting-to-data/data-connectors#allow) property.  Below is a list of the functionality that the local service provider supports.

| Name               | Supports         |
| ------------------ | ---------------- |
| delete             | false            |
| discover           | false            |
| storedProcedure    | false            |
| tableQuery         | true             |
| tableQuery.orderBy | 1 - Single field |
| tableQuery.groupBy | false            |
| test               | false            |
| write              | false            |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wirebootstrap.com/wirebootstrap/connecting-to-data/data-connectors/local-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
