angular-restmod icon indicating copy to clipboard operation
angular-restmod copied to clipboard

$send is not accessible anymore

Open amcdnl opened this issue 10 years ago • 3 comments

I have a model that defines a 'non-restful' method like:

    var model = restmod.model('api/settings').$mix({

        "@loginBanner": function(){
            return this.$send({
                url: this.$url() + '/login-banner',
                method: 'GET'
            });
        }

    });

after updating to latest version, $send is not accessible on this, I have to do this.prototype? ... any thoughts on better usage?

amcdnl avatar Sep 16 '14 20:09 amcdnl

I noticed in some sample code that you can do this.$collection().$send(). I am not really sure what the difference is, though...

scriby avatar Sep 17 '14 17:09 scriby

The common api is not accesible as static methods anymore, this is because the common api is not stateless and static methods should be stateless. I'm working on a small refactoring to provide a way of generating blank objects (not records nor collections) to be able to generate custom requests related to the model but not to any collection or record.

About the @loginBanner method, I think you should consider using a singleton model with relations instead of a custom actions, like this:

var settings = restmod.model().$mix({
  loginBanner: { hasMany: restmod.model(), path: 'login-banner' }
}).$single('api/settings');

// Then do
settings.loginBanner.$fetch();

iobaixas avatar Sep 17 '14 22:09 iobaixas

That seems odd to me :S.

Problem is: I have several of these cases where I need 'one off' methods that don't fall into the standard restful method procedures.

amcdnl avatar Sep 18 '14 12:09 amcdnl