From 8d9b52f51c436601c2e4603b41907b4527d53f94 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Sat, 16 Sep 2023 16:08:23 -0400 Subject: [PATCH] Ajouter dbschema et dbstruct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contiennent respective le schéma de base de donnée et l'objet dbstruct.Presence, pour en manipuler les données --- dbschema/dbschema.go | 11 +++++++++++ dbstruct/dbstruct.go | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 dbschema/dbschema.go create mode 100644 dbstruct/dbstruct.go diff --git a/dbschema/dbschema.go b/dbschema/dbschema.go new file mode 100644 index 0000000..e18b72d --- /dev/null +++ b/dbschema/dbschema.go @@ -0,0 +1,11 @@ +// Package dbschema defines the database schema for the application +package dbschema + +const Schema string = ` +CREATE TABLE IF NOT EXISTS presences ( + id VARCHAR(7) PRIMARY KEY NOT NULL, + at TIMESTAMP NOT NULL, + name VARCHAR(50) NOT NULL, + programme_id NOT NULL +); +` diff --git a/dbstruct/dbstruct.go b/dbstruct/dbstruct.go new file mode 100644 index 0000000..8dd52e7 --- /dev/null +++ b/dbstruct/dbstruct.go @@ -0,0 +1,14 @@ +/* +Package dbstruct provides struct types used to represent data declared in +dbschema and marshalled / unmarshalled by dbclient +*/ +package dbstruct + +import "time" + +type Presence struct { + ID string `db:"id" json:"id" csv:"id"` + At *time.Time `db:"at" json:"at" csv:"at"` + Name string `db:"name" json:"name" csv:"name"` + ProgrammeID string `db:"programme_id" json:"programme_id" csv:"programme_id"` +}