Skip to content

breeze-client / DataService

Class: DataService ​

Defined in: src/metadata/data-service.ts:41

A DataService instance is used to encapsulate the details of a single 'service'; this includes a serviceName, a dataService adapterInstance, and whether the service has server side metadata.

You can construct an EntityManager with either a serviceName or a DataService instance, if you use a serviceName then a DataService is constructed for you. (It can also be set via the EntityManager.setProperties method).

The same applies to the MetadataStore.fetchMetadata method, i.e. it takes either a serviceName or a DataService instance.

Each metadataStore contains a list of DataServices, each accessible via its ‘serviceName’. ( see MetadataStore.getDataService and MetadataStore.addDataService). The ‘addDataService’ method is called internally anytime a MetadataStore.fetchMetadata call occurs with a new dataService ( or service name).

Constructors ​

Constructor ​

new DataService(config?): DataService

Defined in: src/metadata/data-service.ts:86

DataService constructor

ts
var dataService = new DataService({
    serviceName: altServiceName,
    hasServerMetadata: false
});
ts
var metadataStore = new MetadataStore({
    namingConvention: NamingConvention.camelCase
});
ts
return new EntityManager({
    dataService: dataService,
    metadataStore: metadataStore
});

Parameters ​

config? ​

DataServiceConfig

A configuration object.

Returns ​

DataService

Properties ​

adapterInstance? ​

optional adapterInstance?: DataServiceAdapter

Defined in: src/metadata/data-service.ts:49

The DataServiceAdapter implementation instance associated with this EntityManager. Read Only


adapterName ​

adapterName: string

Defined in: src/metadata/data-service.ts:47

The adapter name for the DataServiceAdapter to be used with this service. Read Only


hasServerMetadata ​

hasServerMetadata: boolean

Defined in: src/metadata/data-service.ts:55

Whether the server can provide metadata for this service. Read Only


jsonResultsAdapter ​

jsonResultsAdapter: JsonResultsAdapter

Defined in: src/metadata/data-service.ts:57

The JsonResultsAdapter used to process the results of any query against this DataService. Read Only


serviceName ​

serviceName: string

Defined in: src/metadata/data-service.ts:45

The serviceName for this DataService. Read Only


uriBuilder? ​

optional uriBuilder?: UriBuilderAdapter

Defined in: src/metadata/data-service.ts:53

The UriBuilderAdapter implementation instance associated with this EntityManager. Read Only


uriBuilderName ​

uriBuilderName: string

Defined in: src/metadata/data-service.ts:51

The adapter name for the UriBuilderAdapter to be used with this service. Read Only


useJsonp ​

useJsonp: boolean

Defined in: src/metadata/data-service.ts:62

Whether to use JSONP when performing a 'GET' request against this service. Read Only

Deprecated ​

No effect on Breeze's own transport, which has no JSONP support. Kept because it is part of a serialized DataService, and because a registered (deprecated) ajax adapter can still act on the dataType and crossDomain settings it produces.

Methods ​

qualifyUrl() ​

qualifyUrl(suffix): string

Defined in: src/metadata/data-service.ts:178

Returns a url for this dataService with the specified suffix. This method handles dataService names either with or without trailing '/'s. If the suffix starts with "http" then it will be returned as-is.

Parameters ​

suffix ​

string

{String} The resulting url.

Returns ​

string


toJSON() ​

toJSON(): Object

Defined in: src/metadata/data-service.ts:146

Returns the serializable form of this DataService: serviceName, adapterName, uriBuilderName, hasServerMetadata, useJsonp and the name of its jsonResultsAdapter, leaving out any that are not set. JSON.stringify calls it when MetadataStore.exportMetadata and EntityManager.exportEntities serialize their DataServices; DataService.fromJSON reads it back.

Returns ​

Object


using() ​

using(config): DataService

Defined in: src/metadata/data-service.ts:95

Returns a copy of this DataService with the specified properties applied.

Parameters ​

config ​

DataServiceConfig

The configuration object to apply to create a new DataService.

Returns ​

DataService


fromJSON() ​

static fromJSON(json): DataService

Defined in: src/metadata/data-service.ts:167

Creates a DataService from the output of DataService.toJSON. Used when importing metadata and exported entities. The jsonResultsAdapter name is looked up among the JsonResultsAdapters created so far, so create a custom one before importing.

Parameters ​

json ​

any

A serialized DataService. Its jsonResultsAdapter property is replaced.

Returns ​

DataService

Throws ​

if the named jsonResultsAdapter does not exist.


resolve() ​

static resolve(dataServices): DataService

Defined in: src/metadata/data-service.ts:110

Combines several DataServices into one, taking each property from the first of them that has it set, and filling in the adapters: the named ones, or the defaults. Breeze uses it to combine a query's or save's own DataService with the EntityManager's before each request; applications do not normally need it.

Parameters ​

dataServices ​

DataService[]

The DataServices to combine, most specific first. Entries may be null or undefined. The array is modified.

Returns ​

DataService

Throws ​

if none of them has a serviceName.

Released under the MIT License.