Closed GreenMachine01 closed 1 year ago
From ChatGPT:
Custom Attributes on Entities and Fields Custom attributes are a powerful feature that provides you with the flexibility to add additional metadata or functionality to your entities and fields. They allow for a higher level of customization and control, enabling you to tailor the behavior of your entities and fields to best fit your specific needs.
Adding Custom Attributes to Entities You can add custom attributes to entities by using a simple command format: '@@command([parameters])'.
In this command, replace 'command' with the operation you wish to perform (e.g., 'map'), and 'parameters' with the parameters required for your chosen operation.
For example, if you wanted to create a mapping for an entity named 'users', your command would look like this: '@@map('users')'.
Adding Custom Attributes to Fields Similarly, you can also add custom attributes to fields using a similar command format: '@command([parameters])'.
In this format, replace 'command' with your desired operation (e.g., 'index'), and 'parameters' with the appropriate parameters for that operation.
As an example, if you wanted to index a field named 'username', you would use the following command: '@index('username')'.
Notes
Custom attributes offer an efficient and effective way to enhance your data structure, enabling you to optimize the way you manage, search, and interact with your data. With this feature, you can build systems that are more streamlined, adaptable, and aligned with your unique needs.
Please see the relevant prisma documentation: https://www.prisma.io/docs/concepts/components/prisma-schema/data-model
And in particular these sub-sections:
https://www.prisma.io/docs/concepts/components/prisma-schema/data-model#defining-attributes
https://www.prisma.io/docs/concepts/components/prisma-schema/data-model#native-types-mapping
The instructions are provided as a placeholder for the text field
add field attributes to isPremium
NOTE: There are field attributes such as fields: [fieldName], references: [referenceField]
and @unique
that we already add when a relation is set or the toggle is on
Therefore, the user should be aware of not adding relation attribute where we already added, or add the relation at the other side and then his/her prisma schema will not be valid
And the results:
This one is taken care of in #310.
https://github.com/amplication/amplication/issues/5989 https://github.com/amplication/amplication/issues/5990