vue-api-query
vue-api-query copied to clipboard
Can't build query with nested primaryKey
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.