-
-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
pinia-orm: 1.7.2
Vite: 4.5.0
Vue: 3.3.6
Typescript: 5.2.2
Reproduction
Main User model
// models/main/User.ts
import { Model } from 'pinia-orm'
export default class User extends Model {
static entity = 'users';
static namespace = 'main';
static fields() {
return {
id: this.uid(),
name: this.string(''),
age: this.number(null),
}
}
}Extended User model from another namespace
// models/extended/User.ts
import { Model } from 'pinia-orm';
import MainUser from '@/models/main/User';
export default class User extends Model {
static entity = 'users';
static namespace = 'extended';
static fields() {
return {
id: this.uid(),
user_id: this.attr(''),
user: this.belongsTo(MainUser, 'user_id'),
// ... more fields
}
}
}Make relation
import User from '@/models/extended/User';
const user = useRepo(User).make({
user: {
name: 'John Doe',
age: 30
}
});Describe the bug
When make a model with related one as same entity but different namespace, results was a related model as a same of parent (like it was category and child category).
To solve this, entity must be unique per model. If I not wrong, related models must use $storeName() instead of $entity().
Additional context
No response
Logs
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working