Skip to content

Commit

Permalink
Merge pull request #10 from amplication/fix/mongo-db-deafult-value
Browse files Browse the repository at this point in the history
fix mongoDB deafult value
  • Loading branch information
morhag90 authored Dec 19, 2022
2 parents c5ba819 + 4c7083f commit 8f01fa3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prisma-schema-dsl",
"version": "2.0.2",
"version": "2.0.3",
"description": "JavaScript interface for Prisma Schema DSL",
"main": "dist/index.js",
"scripts": {
Expand Down
8 changes: 6 additions & 2 deletions src/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,14 @@ function printScalarField(
attributes.push("@updatedAt");
}
if (field.default) {
!isMongoDBProvider &&
if (!isMongoDBProvider || !field.isId) {
attributes.push(`@default(${printScalarDefault(field.default)})`);
isMongoDBProvider && field.isId && attributes.push(`@default(auto())`);
}
if (isMongoDBProvider && field.isId) {
attributes.push(`@default(auto())`);
}
}

const typeText = `${field.type}${modifiersText}`;
const attributesText = attributes.join(" ");
return [field.name, typeText, attributesText].filter(Boolean).join(" ");
Expand Down

0 comments on commit 8f01fa3

Please sign in to comment.