Skip to content

Can't build query with nested primaryKey #271

@marksitko

Description

@marksitko

Hey,
first thanks for the great package and your effort!

The primary key of my Model is under data.id, the problem is, that Javascript can't resolve an Object by string dot notation.

It try's to check if my Model instance has a valid ID with the hasId Method. Insides the hasId Method it try's to access the primaryKey through getPrimaryKey() with this[this.primaryKey()];.

This would be equivalent to access an object like this and resolves to undefined:

const o = {
    data: {
        id: 1,
    },
};

o['data.id'];
// my model
export default class User extends Model {
  primaryKey() {
    return 'data.id';
  }

  resource() {
    return 'users';
  }
}

Is there any other solution? If not i think it should be possible to access objects through a provided path as a string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions