Skip to content

Commit

Permalink
feat(generator): add $count fluent API
Browse files Browse the repository at this point in the history
  • Loading branch information
Seven Du committed Feb 27, 2023
1 parent 793fdcf commit 8cc1836
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bin/generator/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,7 @@ extension ModelFluentGenerator on Generator {
return _buildModelResultsCompiler(field, fields: fields);

// If output is `AffectedRowsOutput`, return the affected rows.
} else if (field.outputType.type == 'AffectedRowsOutput' ||
field.outputType.type.endsWith('CountOutputType')) {
} else if (field.outputType.type == 'AffectedRowsOutput') {
final type = _findPrismaOutputType(field.outputType.type);
final fields = type.fields.map((e) => e.name);

Expand Down Expand Up @@ -1063,9 +1062,9 @@ extension ModelDelegateGenerator on Generator {

/// Is model fluent output type
bool _isModelFluentOutputType(dmmf.SchemaType outputType) {
final models = options.dmmf.schema.outputObjectTypes.model;

return models?.any((e) => e.name == outputType.type) == true &&
return options.dmmf.schema.outputObjectTypes.model
?.any((e) => e.name == outputType.type) ==
true &&
!outputType.isList;
}

Expand Down Expand Up @@ -1112,7 +1111,6 @@ extension PrismaOutputTypeGenerator on Generator {
static final _jsonSerializablePrismaOutputTypes = [
(String type) => type.endsWith('GroupByOutputType'),
(String type) => type == 'AffectedRowsOutput',
(String type) => type.endsWith('CountOutputType'),
];

/// Generate prisma output types
Expand Down Expand Up @@ -1173,7 +1171,9 @@ extension PrismaAggregationFluentGenerate on Generator {

/// Is aggregate output type
bool _isAggregate(String type) {
return type.endsWith('AggregateOutputType') || type.startsWith('Aggregate');
return type.endsWith('AggregateOutputType') ||
type.startsWith('Aggregate') ||
type.endsWith('CountOutputType');
}

/// Build aggregate fluent
Expand Down

0 comments on commit 8cc1836

Please sign in to comment.