diff --git a/cache/database/types.go b/cache/database/types.go index b0b3138..eec63ac 100644 --- a/cache/database/types.go +++ b/cache/database/types.go @@ -20,6 +20,7 @@ type Column struct { Constraint string } +// Relationships so to create relationships type Relationships struct { ColumnName string ReferencesTableName string diff --git a/cache/parser/parser.go b/cache/parser/parser.go index fd27391..10514ed 100644 --- a/cache/parser/parser.go +++ b/cache/parser/parser.go @@ -24,11 +24,25 @@ func (s *SParser) Entity(entity entity.Entity) ([]database.Table, error) { // TODO: For `Id` always: `Id TEXT PRIMARY KEY,` // TODO: Maybe always have `NOT NULL` as a constrain. E.g.: name TEXT NOT NULL - //entityBody := entity.Content.Body + entityBody := entity.Content.Body - /*for _, bodyProperty := range entityBody { + // TODO: It needs data type and constrain + var dynamicColumns []database.Column + for key, value := range entityBody { + //dataType := determineDataType(value) + // TODO: Lookup the JsonSchema for the datatype + dynamicColumns = append(dynamicColumns, database.Column{ + ColumnName: key, + DataType: "", //dataType, + Constraint: "", // TODO: Maybe there is something we can use from json schema (unique, require, etc) + }) + } - }*/ + // TODO: + var dynamicRelationships []database.Relationships + for key, value := range entityBody { + dynamicRelationships = append(dynamicRelationships, database.Relationships{}) + } return []database.Table{ {