I have two tables, 'users' and 'clubs,' that are related with a one-to-many relation. This means each user can be associated with many clubs, and each club is owned by one user. However, when attempting to create a new club and set its user to the current user record, an error is encountered: 'Cannot read property 'set' of undefined.'.
here below my implementation
The piece of code that throws the error:
@writer async addClub(name, location) {
const newClub = await this.collections.get('clubs').create( club => {
club.user.set(this) // <= this throws "Cannot read property 'set' of undefined"
club.name = name
club.location =location
})
return newClub
}
I have two tables, 'users' and 'clubs,' that are related with a one-to-many relation. This means each user can be associated with many clubs, and each club is owned by one user. However, when attempting to create a new club and set its user to the current user record, an error is encountered: 'Cannot read property 'set' of undefined.'.
here below my implementation
The piece of code that throws the error:
Models :
List of dependencies for this project:
Babel.config.js