We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
<modelClassName>_id
When using sequelize-typescript and doing .findAll() I get an error saying column.
sequelize-typescript
.findAll()
column
import {Column, DataType, HasOne, Model, PrimaryKey, Table} from "sequelize-typescript" @Table export class User extends Model { @PrimaryKey @Column({type: DataType.UUID, defaultValue: DataType.UUIDV4}) declare id: string @Column name: string @Column email: string }
But, when using the normal sequelize package, the select works as expected and returns the correct data:
sequelize
import {sequelize} from "../Database" import {DataTypes} from "sequelize" export const User = sequelize.define('user', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true }, name: { type: DataTypes.STRING }, email: { type: DataTypes.STRING } })
I also created another model and it seems the extra column name is the model name plus _id.
_id
Why is this extra column added and how can I remove it from selects?
Getting an error
Should not select the <modelClassName>_id extra column
Use sequelize-typescript to create a model and do .findAll() on that model.
import { Sequelize } from "sequelize-typescript"; export const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASSWORD, { host: process.env.DB_HOST, dialect: 'mysql', models: [__dirname + '/Models/**/*.{js,ts}'], logging: process.env.DB_LOGGING === "true", define: { timestamps: false, underscored: false, freezeTableName: true } });
The text was updated successfully, but these errors were encountered:
It seems I had another rogue entity in the project which had relationship properties that were pointing to the User class.
Sorry, something went wrong.
No branches or pull requests
Issue
When using
sequelize-typescript
and doing.findAll()
I get an error sayingcolumn
.But, when using the normal
sequelize
package, the select works as expected and returns the correct data:I also created another model and it seems the extra column name is the model name plus
_id
.Why is this extra column added and how can I remove it from selects?
Versions
Issue type
Actual behavior
Getting an error
Expected behavior
Should not select the
<modelClassName>_id
extra columnSteps to reproduce
Use
sequelize-typescript
to create a model and do.findAll()
on that model.Related code
The text was updated successfully, but these errors were encountered: