Skip to content

$new does not populate primary key field. #386

@werner291

Description

@werner291

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;
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions