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

.$add() returns Invalid Value {} when I pass it a Model as a second parameter. #1625

Closed
2 tasks
clement-cavigniaux-inetum opened this issue Apr 6, 2023 · 1 comment

Comments

@clement-cavigniaux-inetum

Issue

When I use .$add or $set with a Model in second parameter, I have as return: Invalid value {}

Tell me if my code is the problem or not but I can't find anyone in the same case as me on StackOverflow...

Thanks in advance

Versions

  • sequelize: ^6.30.0
  • sequelize-typescript: ^2.1.5
  • typescript: ^4.7.4

Issue type

  • bug report
  • feature request

Actual behavior

Expected behavior

Steps to reproduce

Related code

Service

  const team: Teams = await this.teamModel.findByPk(id);
  const member: User = await this.userService.findOneById(users[0]);
  await team.$set('users', member); // return Invalid value {}

team.entity.ts

import { v4 as uuidv4 } from 'uuid'
import { Table, Column, Model, BelongsToMany, BelongsTo, DataType } from 'sequelize-typescript';
import User from 'src/user/entities/user.entity';
import UserTeams from './teamUsers.entity';


@Table({ timestamps: true })
export default class Teams extends Model {

    @Column({ type: DataType.UUID, defaultValue: () => uuidv4(), primaryKey: true, unique: true, allowNull: false })
    id: string;

    @Column({ type: DataType.STRING, allowNull: false })
    name: string;

    //@BelongsTo(() => Projects, { foreignKey: 'id', as: 'project' })
    @Column({ type: DataType.STRING, allowNull: false })
    projectID: string;

    @BelongsToMany(() => User, () => UserTeams)
    users!: User[]
}
@clement-cavigniaux-inetum
Copy link
Author

Go to TypeORM

@clement-cavigniaux-inetum clement-cavigniaux-inetum closed this as not planned Won't fix, can't repro, duplicate, stale Apr 19, 2023
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