🎉 release: v2.6.0
🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or tweeting about the release. 🌟
New requirements
Breaking change: You are now asked to install the freezed
package:
dart pub add freezed -d
Breaking changes
All input classes types will be reset!
The Map input by forJson needs to follow the freezed
rules, examples:
final PrismaNull $null = PrismaNull.fromJson({}); // An empty map must be entered to indicate PrismaNull
final UserWhereInput where = UserWhereInput.fromJson({
'id': {
'runtimeType': 'withInt', // The runtimeType must be entered, name is `UserWhereInput_id` factory name.
'value': 1,
},
});
PrismaUnion
has been removed:
Before:
final data = UserCreateInput(
name: PrismaUnion.zero("Seven"),
);
Now:
final data = CreateOneUserData.withUserCreateInput( // OR `withUserUncheckedCreateInput`
UserCreateInput(
name: "Seven",
),
);
Note:
withUserCreateInput
andwithUserUncheckedCreateInput
are generated byprisma_client.dart
file.
Model delegates
All delegat methods input classes are now generated by freezed
package, Example(create a user):
Before:
final user = await prisma.user.create(
data: UserCreateInput(
name: PrismaUnion.zero("Seven"),
),
);
Now:
final user = await prisma.user.create(
data: CreateOneUserData.withUserUncheckedCreateInput(
UserUncheckedCreateInput(
name: 'Seven',
email: 'seven@odroe.com',
),
),
);
Seems like it's getting troublesome?
We are preparing to support more Prisma functions in the future, such as REF query.
In addition, we are preparing for the next Dart 3, and we expect that in Dart 3, there is no need to run additional commands before compilation to complete the serialization of input and output types.
Since full input types are relatively cumbersome for web applications, we recommend using the fromJson method to create inputs.
Because the current input is the complete Prisma input type, it is expected to be improved in Dart 3. Currently, Dart 2 does not support union types. Our strategy is to create as many types as possible to meet all Prisma input requirements.