目前我必须这样做:
var manager = new breeze.EntityManager({ dataService: ds });
我想这样做
var manager = new breeze.EntityManager(ds);
必须传递一个显式的散列对象似乎太隆重了。
目前我必须这样做:
var manager = new breeze.EntityManager({ dataService: ds });
我想这样做
var manager = new breeze.EntityManager(ds);
必须传递一个显式的散列对象似乎太隆重了。
最基本的 EntityManager 可以只用一个服务名称来构建
var entityManager = new EntityManager( "breeze/NorthwindIBModel");
这与使用以下配置对象调用它相同
var entityManager = new EntityManager( {serviceName: "breeze/NorthwindIBModel" });
然而,通常配置对象将不仅仅包含“服务名称”;
var metadataStore = new MetadataStore(...);
var entityManager = new EntityManager( {
serviceName: "breeze/NorthwindIBModel",
metadataStore: metadataStore
});
Breeze API Docs 中有更多信息。
This is common practice in JS to supply only one parameter - object literal - instead of more simple params (i.e. string, number...). This object has usually default implementations in vendor's library. Default implementation is enhanced by values you specify when calling method. Often the defaults object is singleton you can redefine when starting your app/code.
And you can always create your API or wrapper around 3rd party libraries, this is good practice. Just example:
var myApp = function (breeze, ds) {
function createEntityManager() {
return breeze.EntityManager({ dataservice: ds });
}
return {
createEntityManager: createEntityManager,
}
};
myApp(breeze, ds);
var mgr = myApp.createEntityManager();