Comments (4)
As given you need to make a primary key for the model otherwise a id primarykey gets added automatically. If you don't want id as your primary key then mark another field as primary key as below, you can use email ( which should be unique) and gives you a string primary key.
`@Table({
tableName: 'USERS',
timestamps: false,
})
export class User extends Model {
@column({ field: 'NAME' })
name: string;
@PrimaryKey
@column({ field: 'EMAIL' })
email: string;
}`
from sequelize-typescript.
You need to make one of the fields a primary key otherwise id is auto added as primary key
Also the error you are receiving is due to the model not being attached to the Sequelize instance, you can do that in one of two ways following the docs: https://github.com/sequelize/sequelize-typescript#configuration
from sequelize-typescript.
Do you have an alternative solution for fixing the issue in the model file?
from sequelize-typescript.
give a @PrimaryKey in other filed
from sequelize-typescript.
Related Issues (20)
- `order` property not assignable to `FindOptions` if stored in a variable
- Problem For `Rename Column` With `Keep Rows` in Sequelize
- Associations keys not replaced by include
- Model is error HOT 1
- Cannot use @DefaultScope() simultaneously in two related Models HOT 2
- @Unique and @Column decorators unique constraint name on postgresql/sqlite
- TS error when tried to change createdAt, updatedAt columns type to something else HOT 1
- Support Sequelize.literal on VIRTUAL data type
- setting custom name for foreign key constraint HOT 1
- Vulnerability issue from Snyk scan HOT 3
- Can this project be used with vitest?
- how to hide password when get the model HOT 2
- Failed to create index with @Index Decorator when using table option of undescore:true
- Getting an error when trying to use MySQL POINT type HOT 1
- Adding relation between specified instances and source instance in a M:N relationship with multiple foreign keys not supported
- ModelNotInitializedError: Model not initialized: Member "create" cannot be called [Model] needs to be added to a Sequelize instance. HOT 1
- Why is using soft deletion ineffective
- it only brings me a record in one to many HOT 1
- can't use @Index decorator with indexes at the model options HOT 2
- ● Test suite failed to run @Table annotation is missing on class "API" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sequelize-typescript.