Property 'belongsToMany' does not exist on type 'typeof ...
See original GitHub issueThank you for creating this package!
Reproduction
I created a simple model but the .belongsToMany gives me the error Property 'belongsToMany' does not exist on type 'typeof ...
Steps to reproduce the behavior
- Install piniaorm
- Create a model (group.ts)
import { Model } from "pinia-orm";
import GroupMember from "./GroupMember";
import Member from "./Member";
export default class Group extends Model {
static entity = "Group";
static fields() {
return {
id: this.uid(),
title: this.string(""),
description: this.string(""),
members: this.belongsToMany(Member, GroupMember, "group_id", "member_id"),
};
}
}
- See that your editor (Webstorm in my case) says that belongsToMany does not exist.
Expected behavior
I would expect this.belongsToMany to exist and behave just like the original docs described it. https://vuex-orm.org/guide/model/relationships.html#many-to-many
Actual behavior
It says belongsToMany does not exist.
Additional information
If you didn’t implement belongsToMany it might be good to put this in the README.md
Issue Analytics
- State:
- Created a year ago
- Comments:14
Top Results From Across the Web
Property 'User' does not exist on type 'typeof db' sequelize in ...
When I tried to get User from model. I get an error: Property 'User' does not exist on type 'typeof db'. How can...
Read more >types/sequelize Conflicting exports of Model #16588 - GitHub
This results in Object literal may only specify known properties, and 'classMethods' does not exist in type 'ModelOptions<Model<any, ...
Read more >Typescript relationships - Forest Admin Developers Community
Model creation error: TypeError: Cannot read property 'companyIdKey' of ... Property 'associate' does not exist on type 'typeof Company'.
Read more >TypeScript - Sequelize
As Sequelize heavily relies on runtime property assignments, TypeScript won't be very useful out of the box. A decent amount of manual type...
Read more >sequelize-typescript - npm
The model needs to extend the Model class and has to be annotated with the @Table decorator. All properties that should appear as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you explain your goal I think we will find an solution 😃
As I understand you want to add a member to a group? If yes, you need the model group and member.
Solution 1: Add an belongsto fields to the member which points to the group model Solution 2: Add the fields hasMany to the group model and point to member
I finally got it to work like this:
The only problem is that human.groups returns a list of GroupMembership and not groups. I’ll add a method in the model to handle that until the ManyToMany is implemented. By the way I am using vuex-orm next and not pinia yet.