Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

breeze fetch meta data if not present

I have an angular / breeze / webapi app which works great except if I refresh a page which has a EntityQuery to return one entity. It then complains that the metadata is not available as the entityquery does not trigger a metadata fetch, unlike a standard query.

If we have reached the page from a previous angular page which has fired a standard breeze query then the metadata is already there and we have no problem.

So question is, how do I check the metadata exists and trigger the metadata call if it is not already done?

Many thanks for any help you can give me.

like image 989
Richard Avatar asked Nov 23 '25 05:11

Richard


1 Answers

Try something like this:

function fetchMetadata() {
    var manager = new breeze.EntityManager("api/breeze");
    if (manager.metadataStore.isEmpty()) {
        return manager.fetchMetadata();
    }

    return Q.resolve();
}

function start() {
     fetchMetadata().then(function () {
            // Metadata fetched.
            // Do something here.
     });
}
like image 78
Toast Man Avatar answered Nov 26 '25 07:11

Toast Man



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!