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

$new does not populate primary key field.

Open werner291 opened this issue 8 years ago • 0 comments

Hello!

I love this library, it handles collections and relations so much better than ngResource (that is: it handles them at all.)

The issue:

Calling $new( ) does populate the $pk field, but not the "id" field.

restmodProvider.rebase({
    $config: {
        primaryKey: 'id'
    },
    })

var SomeModel = restmod.model('/foo')

SomeModel.$new(1).id // <== Is undefined.

A workaround at the moment is with this hook:

'after-init': function() {
if (typeof this.id === 'undefined') {
    this.id = this.$pk;
}
}

werner291 avatar Aug 02 '16 14:08 werner291