Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build query with nested primaryKey #271

Open
marksitko opened this issue Feb 24, 2023 · 0 comments
Open

Can't build query with nested primaryKey #271

marksitko opened this issue Feb 24, 2023 · 0 comments

Comments

@marksitko
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant