When using `@ignore` for some fields, there is no `create` method in the model
See original GitHub issueBug description
When using @ignore
for some fields, there is no create
method in the model. I’m ignoring just two fields but the rest should be available.
How to reproduce
Define this model:
model User {
id Int @id @default(autoincrement())
email String @unique
password String
createdAt DateTime @default(now()) @ignore
updatedAt DateTime @updatedAt @ignore
remarks String?
}
Then generate it. Then you cannot create a user using this code:
await this.prismaService.user.create({ data: newUser });
Because of this error:
Property 'create' does not exist on type 'UserDelegate<RejectOnNotFound | RejectPerOperation | undefined>'.ts(2339)
Expected behavior
The create
method should be there!
Prisma information
Environment & setup
- OS: Ubuntu 21.10
- Database: PostgreSQL
- Node.js version: 16.13.1
Prisma Version
3.8.1
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Laravel - Ignoring fields that don't exist when using model
I can't make Laravel ignore fields that don't exist in the database when present in Eloquent's create method or when seeding the database....
Read more >Jackson Ignore Properties on Marshalling - Baeldung
We can ignore specific fields at the class level, using the @JsonIgnoreProperties annotation and specifying the fields by name:
Read more >How to ignore properties with System.Text.Json | Microsoft Learn
To ignore read-only fields when serializing fields, use the JsonSerializerOptions.
Read more >3 ways to ignore null fields while converting Java object to ...
And, if that's precisely what you want, then you can ignore the fields with null values using @JsonInclude annotation in Jackson. Btw, if...
Read more >How can we ignore the fields during JSON serialization in Java?
If there are fields in Java objects that do not wish to be serialized, we can use the @JsonIgnore annotation in the Jackson...
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
Sounds good to me 👍
Maybe I’m not understanding how
@ignore
was designed to be used.@ignore
would in theory achieve this desired outcome according to the docs, so it doesn’t feel like a feature is missing?It seems like the bug goes away when the field is marked optional, FWIW.