2024-02-09 - Per Service Schemas Docs
(Redirected from Per Service Schemas Docs)
Jump to navigation
Jump to search
Per Service Schemas
Describe object schema design and workflow.
Schema Description
- objectSchema is an object that shows data models in service.
- relationshipSchema is an object that describes a relation between objectSchema.
- refRelationshipSchema is an object that references to relationshipSchema in another service
Creating schema's rules
- See schema pattern in Per Service Schemas
- If not follow rules when creating schema in service. This will cause the developer to not generate code or upload schema to s3.
- When finished create schema should run npm scripts: npm run validateSchema. This script is used to validate schema inside the service.
Rules for creating objectSchema
- Don’t have duplicate fieldName
- FieldName in identifier should exist in objectSchema.fieldNames
- fieldName that used in identifiers should set canUpdate = false
- Don’t have duplicate tableName in storageResources.type dynamoDB of objectSchema
Rules for creating addOnDatastructure:versionedData
- Don’t have duplicate versionedData.versionedDataLabel in addOnDataStructure
- Don’t have duplicate fieldName with objectSchema and other versionedData
Per service scripts and lambda for schema
- scripts: npm run generateCode
- generate lambda in the local computer
- guide for generate code
- generate lambda in the local computer
- scripts: npm run validateSchema
- validate schema in the local computer
- lambda: UploadSchemaHdrInv
- use to upload schema to s3 after deploy.
S3 format of objectSchema
LinkByLinkTypeId
- location: perServiceSchemas/{serviceTag}/Relationships/LinkByLinkTypeId/{linkTypeId}.json
{
"relType": {
"relationshipTag": "has",
"serviceTag": "EmptyService"
},
"canDelete": false,
"storageResources": { // storageResources of each links
"graph1": {
"storageType": "dynamoDB"
}
},
"from": {
"objType": {
"serviceTag": "EmptyService",
"objectType": "storage1"
},
"linkType": "one",
"requiredOnCreate": false,
"handler": false
},
"to": {
"objType": {
"serviceTag": "EmptyService",
"objectType": "warehouse"
},
"requiredOnCreate": false,
"linkType": "many",
"handler": true
}
}