From bd98c4a45bec95946df9aa02011a60d7f58f9df8 Mon Sep 17 00:00:00 2001 From: jnbdz Date: Mon, 18 Nov 2024 00:01:11 -0500 Subject: [PATCH] Added loops for relationships and columns. Started. --- cache/database/types.go | 1 + cache/parser/parser.go | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) 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{ {