diff options
author | Yulqen <246857+yulqen@users.noreply.github.com> | 2024-04-23 11:22:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-23 11:22:21 +0100 |
commit | ceca6fa956b21c43263e53c328d619c4ede21914 (patch) | |
tree | a48384210cdc168e3bd3ccff6d6d516eeed9e748 /internal/models/operation.go | |
parent | 8b084e9fe7a5f3a04c32daf9a24f7f2cf67300f9 (diff) | |
parent | 0f951dcf029d4af284467543a3afdf5bf6581a20 (diff) |
Merge pull request #22 from defencedigital/pyswitch
switched to Django
Diffstat (limited to '')
-rw-r--r-- | internal/models/operation.go | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/internal/models/operation.go b/internal/models/operation.go deleted file mode 100644 index ecfd31b..0000000 --- a/internal/models/operation.go +++ /dev/null @@ -1,52 +0,0 @@ -package models - -import ( - "database/sql" - "time" -) - -type Operation struct { - ID int - Name string - Description string - Created time.Time - OrganisationName string - EngagementStrategies []EngagementStrategy -} - -type OperationModel struct { - DB *sql.DB -} - -func (m *OperationModel) ListAll() ([]Operation, error) { - - stmt := `SELECT op.id, op.name, op.description, op.created, org.name - FROM operations op - INNER JOIN organisations org ON op.organisation_id=org.id` - - // stmt := `SELECT * FROM operations` - - rows, err := m.DB.Query(stmt) - if err != nil { - return nil, err - } - - defer rows.Close() - - var ops []Operation - - for rows.Next() { - var o Operation - err = rows.Scan(&o.ID, &o.Name, &o.Description, &o.Created, &o.OrganisationName) - if err != nil { - return nil, err - } - - ops = append(ops, o) - } - - if err = rows.Err(); err != nil { - return nil, err - } - return ops, err -} |