WireBootstrap
HomeDocsBuySupport
  • Introduction
  • Overview
  • Getting Started
  • Installation
  • Connecting to Data
    • Data Connectors
      • SQL Data
      • Custom Web Services
      • Local Data
      • Other Sources
    • Data Sources
    • Discovery
    • Building a Data Connector
  • Working With Queries
    • Select Queries
      • Query Extensions
    • Stored Procedures
    • Custom Web Services
    • Executing Queries
    • ORM
  • Writing Data
  • Updates
  • Deletes
  • Working with DataTables
    • Introduction
    • Filter and Sort
    • Select and Calculate
    • Joins
    • Rows
    • Columns
  • Working with DataSets
  • Introduction
  • Executing Queries
  • Transforms
  • Writing Data
  • Data Events
  • Working with Components
    • Introduction
    • Encapsulation
    • Configuration
      • Data
      • Events
      • Observables
      • Validation
      • Display
      • Vendor
      • Custom
    • Component
    • Web Frameworks
    • Building a Component
      • Hello World
      • Data Events
      • DataSets
  • Working With Data Events
    • Introduction
    • Event Basics
    • Event Data
    • Event Actions
  • Working with Themes
    • Introduction
    • Sample Data
    • Libraries
    • Pages
    • Building a Theme Project
  • Utilities
    • Formatting
    • Expressions
    • Collections
    • Spinners
    • Copy and Merge
    • Validation
    • Loading Assets
    • Service Calls
    • Download Files
    • Browser Location
    • Types
    • Promise
  • Reference
    • wire
      • wire.Collection
      • wire.download
      • wire.validate
    • wire.data
      • wire.data.DataEvent
      • wire.data.DataModel
      • wire.data.DataPromise
      • wire.data.DataSet
      • wire.data.DataSource
      • wire.data.DataTable
        • Columns
        • Rows
      • wire.data.StoredProcedure
      • wire.data.TableQuery
    • wire.ui
      • wire.ui.Component
      • wire.ui.validate
Powered by GitBook
On this page
  • Configuration
  • Data Models
  • Security

Was this helpful?

  1. Connecting to Data

Data Sources

PreviousOther SourcesNextDiscovery

Last updated 1 year ago

Was this helpful?

In developing WireBootstrap applications, most application code and all components communicate with data services through a object. This object is located at wire.data.DataSource.

Configuration

//
// Create a new data source object from a CSV file
//
const accountService = new wire.data.DataSource("local", {
    ...
    Provider: {
        Csv: { url: "./data/sales.csv" }
    }
});

The data source constructor takes two parameters. The first is the service provider key. This tells the data source which to use with the data service.

The second parameter is the configuration for the data source. This configuration has two parts. The root properties are attributes of the data source object. These settings are independent of any service provider. One of the root parameters on the data source is the Provider attribute. This attribute is the root of the configuration for the service provider. Any configuration in this object will be specific to the service provider.

In the example above, the Csv configuration object is only valid for the specified in the first parameter local.

Data Models

Data models contain meta data about the data returned from a data service. Data models are a convenient way to share data attributes such as friendly labels or numeric formatting across any queries that are run through a data source with a model set up. This meta data is also available to any WireBootstrap component for display.

Data models are set up on a data source. A data model is meta data about fields in the data service that will be added to result sets returned as objects. The meta data is set up by the data source once it receives the results from the data service. Meta data for each field is stored in the Columns attribute on the data table.

In the following example, any query that returns the Sales or Date field from the data service will have meta data attached to the respective columns in any data table.

const accountService = new wire.data.DataSource("local", {
    ...
    Model: new eb.data.DataModel({
        Fields: [
            
            // Use 'Revenue' as the UI label for this field
            // Format the field as currency with 2 decimal places
            { Entity: "Facts", Name: "Sales_Stage", Alias: "Revenue", Format: "C2" },
            
            // Use 'Date' as the UI label for this field
            // Format the field as a date using the the third party library 'moment.js'
            { Entity: "Facts", Name: "Date_Stage", Alias: "Date", Format: (value) => {
                return moment(value).format("MM/DD/YYYY");
            }}
            
        ]
    })
});

Security

const accountService = new wire.data.DataSource("custom", {
    Headers: {"Authorization": "Bearer " + "[accessToken]"}
}

Methods on the DataSource object can also be used to set authorization.

accountService.useBearerAuth("[accessToken]");
...
accountService.useBasicAuth("[user]", "[password]");

To set security on calls to a data service, set the Headers property on the data source configuration using standard .

Visit the reference for more on data sources. Visit the service provider documentation for details on configuration for a specific service provider.

HTTP Authorization
wire.data.DataSource
DataSource
local service provider
DataTable
service provider