> For the complete documentation index, see [llms.txt](https://docs.wirebootstrap.com/query-service/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/query-service/sample-project/page-data.md).

# Page Data

The sample application contains one page called `index.html` and exists in the root of the project directory.

The page data module handles the data access concerns for the page.  In the sample application, the page data module for the `index.html` page is `index.data.js`. &#x20;

## DataSource

The data module defines a [WireBootstrap DataSource](https://docs.wirebootstrap.com/wirebootstrap/reference/wire.data/wire.data.datasource) object called `datasource` that is used to query databases using the query service. &#x20;

```javascript
 datasource = new wire.data.DataSource("sql", {
    ServiceRoot: "http://localhost:1895",
    Provider: {
        ServiceId: null,
        SecretKey: null,
        ConnectionId: null
    }
});
```

Properties on the object are bound to UI components in the [Page Controller](/query-service/sample-project/page-controller.md).  If values are set on the object, they will be set in their respective components by default when the page loads.  See [Service Provider](/query-service/service-provider.md) for setting the data source configuration `Provider` attributes when working with the query service.

## Entities

The `getEntities` method on the page data module uses a data source [discover](https://docs.wirebootstrap.com/wirebootstrap/connecting-to-data/discovery) method to retrieve a list of tables and views in the source database per the connection details entered in the UI and set on the `datasource` object.

```javascript
getEntities(callback) {

    this.datasource.discoverEntitiesAsync().done((entities) => {
    
        const table = this.datasource.getResponseTable(entities);
        
        callback(table);

    });
    ...
}
```

## Sample Data

The `getSampleDataSet` method on the page data module returns a dataset that uses the `datasource` and includes a query for the `top N` records from an `entity` that is passed in as a parameter the the method.  This dataset is used as the data binding for the grid on the page controller module.

```javascript
getSampleDataSet(entity) {

    return new wire.data.DataSet({
        Source: this.datasource,
        Query: wire.data.select().top(5).from(entity)
    });

}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.wirebootstrap.com/query-service/sample-project/page-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
