breeze-client / JsonResultsAdapter
Class: JsonResultsAdapter
Defined in: src/metadata/data-service.ts:274
A JsonResultsAdapter instance is used to provide custom extraction and parsing logic on the json results returned by any web service. This facility makes it possible for breeze to talk to virtually any web service and return objects that will be first class 'breeze' citizens.
Constructors
Constructor
new JsonResultsAdapter(
jsConfig):JsonResultsAdapter
Defined in: src/metadata/data-service.ts:331
JsonResultsAdapter constructor
Parameters
jsConfig
A configuration object.
Returns
JsonResultsAdapter
Example
//
var jsonResultsAdapter = new JsonResultsAdapter({
name: "test1e",
extractResults: function(json) {
return json.results;
},
visitNode: function(node, mappingContext, nodeContext) {
var entityType = normalizeTypeName(node.$type);
var propertyName = nodeContext.propertyName;
var ignore = propertyName && propertyName.substr(0, 1) === "$";
return {
entityType: entityType,
nodeId: node.$id,
nodeRefId: node.$ref,
ignore: ignore,
passThru: false // default
};
}
});
var dataService = new DataService( {
serviceName: "breeze/foo",
jsonResultsAdapter: jsonResultsAdapter
});
var entityManager = new EntityManager( {
dataService: dataService
});Properties
extractDeletedKeys?
optionalextractDeletedKeys?: (data) =>any[]
Defined in: src/metadata/data-service.ts:290
A function that is called once per save operation to extract any deleted keys from any json received over the wire. Must return an array. This method has a default implementation which is to simply returns the "deletedKeys" property from any json returned as a result of executing the save.
Parameters
data
Returns
any[]
extractKeyMappings
extractKeyMappings: (
data) =>KeyMapping[]
Defined in: src/metadata/data-service.ts:287
A function that is called once per save operation to extract the key mappings from any json received over the wire. Must return an array. This method has a default implementation which simply returns the "keyMappings" property from any json returned as a result of executing the save.
Parameters
data
Returns
extractResults
extractResults:
Function
Defined in: src/metadata/data-service.ts:281
A Function that is called once per query operation to extract the 'payload' from any json received over the wire. This method has a default implementation which simply returns the "results" property from any json returned as a result of executing the query.
extractSaveResults
extractSaveResults:
Function
Defined in: src/metadata/data-service.ts:284
A function that is called once per save operation to extract the entities from any json received over the wire. Must return an array. This method has a default implementation which simply returns the "entities" property from any json returned as a result of executing the save.
name
name:
string
Defined in: src/metadata/data-service.ts:278
The name of this adapter. This name is used to uniquely identify and locate this instance when an 'exported' JsonResultsAdapter is later imported.
visitNode
visitNode:
Function
Defined in: src/metadata/data-service.ts:292
A visitor method that will be called on each node of the returned payload.