Constructs a new MetadataStore.
let ms = new MetadataStore();
The store can then be associated with an EntityManager
let entityManager = new EntityManager( {
serviceName: "breeze/NorthwindIBModel",
metadataStore: ms
});
or for an existing EntityManager
// Assume em1 is an existing EntityManager em1.setProperties( { metadataStore: ms });
Configuration settings .
An BreezeEvent that fires after a MetadataStore has completed fetching metadata from a remote service.
The LocalQueryComparisonOptions associated with this MetadataStore. Read Only
The NamingConvention associated with this MetadataStore. Read Only
The version of any MetadataStores created by this class
Adds a DataService to this MetadataStore. If a DataService with the same serviceName is already in the MetadataStore an exception will be thrown.
The DataService to add
(default=false) Permit overwrite of existing DataService rather than throw exception
Adds an EntityType to this MetadataStore. No additional properties may be added to the EntityType after its has been added to the MetadataStore.
Exports this MetadataStore to a serialized string appropriate for local storage. This operation is also called internally when exporting an EntityManager.
// assume ms is a previously created MetadataStore
let metadataAsString = ms.exportMetadata();
window.localStorage.setItem("metadata", metadataAsString);
// and later, usually in a different session imported
let metadataFromStorage = window.localStorage.getItem("metadata");
let newMetadataStore = new MetadataStore();
newMetadataStore.importMetadata(metadataFromStorage);
A serialized version of this MetadataStore that may be stored locally and later restored.
Fetches the metadata for a specified 'service'. This method is automatically called internally by an EntityManager before its first query against a new service. Async
Usually you will not actually process the results of a fetchMetadata call directly, but will instead ask for the metadata from the EntityManager after the fetchMetadata call returns.
let ms = new MetadataStore();
// or more commonly
// let ms = anEntityManager.metadataStore;
ms.fetchMetadata("breeze/NorthwindIBModel").then(function(rawMetadata) {
// do something with the metadata
}).catch(function(exception) {
// handle exception here
});
Either a DataService or just the name of the DataService to fetch metadata for.
Function called on success.
Function called on failure.
Promise
Returns an EntityType or null given its name.
// assume em1 is a preexisting EntityManager
let locType = em1.metadataStore.getAsComplexType("Location");
or to throw an error if the type is not found
let badType = em1.metadataStore.getAsComplexType("Foo", false);
// badType will not get set and an exception will be thrown.
(default=false) Whether to throw an error if the specified EntityType is not found.
The EntityType. ComplexType or 'null' if not not found.
Returns an EntityType or null given its name.
// assume em1 is a preexisting EntityManager
let odType = em1.metadataStore.getAsEntityType("OrderDetail");
or to throw an error if the type is not found
let badType = em1.metadataStore.getAsEntityType("Foo", false);
// badType will not get set and an exception will be thrown.
(default=false) Whether to throw an error if the specified EntityType is not found.
The EntityType. ComplexType or 'null' if not not found.
Returns the DataService for a specified service name
// Assume em1 is an existing EntityManager.
let ds = em1.metadataStore.getDataService("breeze/NorthwindIBModel");
let adapterName = ds.adapterName; // may be null
The service name.
The DataService with the specified name.
Returns an EntityType or a ComplexType given its name.
Either the fully qualified name or a short name may be used. If a short name is specified and multiple types share that same short name an exception will be thrown.
(default=false) Whether to throw an error if the specified EntityType is not found.
The EntityType. ComplexType or 'null' if not not found.
Returns a fully qualified entityTypeName for a specified resource name. The reverse of this operation can be obtained via the EntityType.defaultResourceName property
Returns an array containing all of the EntityTypes or ComplexTypes in this MetadataStore.
// assume em1 is a preexisting EntityManager
let allTypes = em1.metadataStore.getEntityTypes();
Returns an EntityType or a ComplexType given its name.
// assume em1 is a preexisting EntityManager
let odType = em1.metadataStore.getStructuralType("OrderDetail");
or to throw an error if the type is not found
let badType = em1.metadataStore.getStructuralType("Foo", false);
// badType will not get set and an exception will be thrown.
Either the fully qualified name or a short name may be used. If a short name is specified and multiple types share that same short name an exception will be thrown.
(default=false) Whether to throw an error if the specified EntityType is not found.
The EntityType. ComplexType or 'null' if not not found.
Returns whether Metadata has been retrieved for a specified service name.
// Assume em1 is an existing EntityManager.
if (!em1.metadataStore.hasMetadataFor("breeze/NorthwindIBModel"))) {
// do something interesting
}
The service name.
Whether metadata has already been retrieved for the specified service name.
Imports a previously exported serialized MetadataStore into this MetadataStore.
// assume ms is a previously created MetadataStore
let metadataAsString = ms.exportMetadata();
window.localStorage.setItem("metadata", metadataAsString);
// and later, usually in a different session
let metadataFromStorage = window.localStorage.getItem("metadata");
let newMetadataStore = new MetadataStore();
newMetadataStore.importMetadata(metadataFromStorage);
A previously exported MetadataStore.
Allows custom metadata to be merged into existing metadata types.
This MetadataStore.
Returns whether this MetadataStore contains any metadata yet.
// assume em1 is a preexisting EntityManager;
if (em1.metadataStore.isEmpty()) {
// do something interesting
}
Provides a mechanism to register a 'custom' constructor to be used when creating new instances of the specified entity type. If this call is not made, a default constructor is created for the entity as needed. This call may be made before or after the corresponding EntityType has been discovered via Metadata discovery.
let Customer = function () {
this.miscData = "asdf";
};
Customer.prototype.doFoo() {
...
}
// assume em1 is a preexisting EntityManager;
em1.metadataStore.registerEntityTypeCtor("Customer", Customer);
// any queries or EntityType.create calls from this point on will call the Customer constructor
// registered above.
The name of the EntityType or ComplexType.
The constructor for this EntityType or ComplexType; may be null if all you want to do is set the next parameter.
A function or the name of a function on the entity that is to be executed immediately after the entity has been created and populated with any initial values. Called with 'initFn(entity)'
A function that is executed immediately after a noTracking entity has been created and whose return value will be used in place of the noTracking entity.
Associates a resourceName with an entityType.
This method is only needed in those cases where multiple resources return the same entityType. In this case Metadata discovery will only determine a single resource name for each entityType.
The resource name
If passing a string either the fully qualified name or a short name may be used. If a short name is specified and multiple types share that same short name an exception will be thrown. If the entityType has not yet been discovered then a fully qualified name must be used.
General purpose property set method
// assume em1 is an EntityManager containing a number of existing entities.
em1.metadataStore.setProperties( {
version: "6.1.3",
serializerFn: function(prop, value) {
return (prop.isUnmapped) ? undefined : value;
}
)};
An object containing the selected properties and values to set.
Used to register a constructor for an EntityType that is not known via standard Metadata discovery; i.e. an unmapped type.
The constructor function for the 'unmapped' type.
An interceptor function
Creates a new MetadataStore from a previously exported serialized MetadataStore
// assume ms is a previously created MetadataStore
let metadataAsString = ms.exportMetadata();
window.localStorage.setItem("metadata", metadataAsString);
// and later, usually in a different session
let metadataFromStorage = window.localStorage.getItem("metadata");
let newMetadataStore = MetadataStore.importMetadata(metadataFromStorage);
A previously exported MetadataStore.
A new MetadataStore.
Dev Only - for use when creating a new MetadataParserAdapter
Dev Only - for use when creating a new MetadataParserAdapter
Generated using TypeDoc
An instance of the MetadataStore contains all of the metadata about a collection of EntityType's. MetadataStores may be shared across EntityManager's. If an EntityManager is created without an explicit MetadataStore, the MetadataStore from the MetadataStore.defaultInstance property will be used.