You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extend your script to use named command line arguments, e.g. with argparse
the name of the data model, e.g. "model" : "book". Extract this from the BrApi-file-name.
the storage-type (command line arg -s or --storage-type), e.g. "storageType" : "sql". Provide an optional third argument to your script. This is the storage type to be used for all generated Zendro models. (for details see below)
add a default primary key to all data models (command line argument -p or --primary-key-name). By default this is set to id and of type Int.
Add another optional argument (-t or --primary-key-type). By default this is Int but can be String. Make sure to validate this and inform the user about the possible two types (see docu of argparse about how to add usage information).
In the usage of your programm inform the user that if any of the primary key related arguments are given, identifiers are created that Zendro will not take care of automatically, meaning that no database sequence will be used to automatically populate the primary key (id) property of new records. However, the user can write a Zendro migration to add e.g. a database sequence to do exactly that for his custom primary keys.
Make sure the current properties become the key-value pairs of an attributes object of the Zendro definition. See this example for details:
If this argument is not provided, use sql as default storage-type. If it is provided, validate that it is correctly spelled and one of the accepted storage-types (see Zendro documentation). If not inform with a meaningful error message. Put this optional argument in your usage information, too.
The text was updated successfully, but these errors were encountered:
{
"model": "Study",
"storageType": "sql",
"attributes": {
"primary_id": "Int",
"active": {
"description": "Is this study currently active",
"type": "Boolean"
},
"commonCropName": {
"description": "Common name for the crop associated with this study",
"type": "String"
},
"culturalPractices": {
"description": "MIAPPE V1.1 (DM-28) Cultural practices - General description of the cultural practices of the study.",
"type": "String"
}
}
Extend the existing code to include model name and storage information
A typical Zendro data model definition requires these two additional arguments:
argparse
"model" : "book"
. Extract this from the BrApi-file-name.-s
or--storage-type
), e.g."storageType" : "sql"
. Provide an optional third argument to your script. This is the storage type to be used for all generated Zendro models. (for details see below)-p
or--primary-key-name
). By default this is set toid
and of typeInt
.-t
or--primary-key-type
). By default this isInt
but can beString
. Make sure to validate this and inform the user about the possible two types (see docu ofargparse
about how to add usage information).id
) property of new records. However, the user can write a Zendro migration to add e.g. a database sequence to do exactly that for his custom primary keys.attributes
object of the Zendro definition. See this example for details:Storage-Type details
If this argument is not provided, use
sql
as default storage-type. If it is provided, validate that it is correctly spelled and one of the accepted storage-types (see Zendro documentation). If not inform with a meaningful error message. Put this optional argument in your usage information, too.The text was updated successfully, but these errors were encountered: