add v1 GET endpoints

This commit is contained in:
Stanislaw
2022-12-25 23:14:45 +01:00
parent 3f17d6e985
commit 92ece902f7
12 changed files with 258 additions and 33 deletions

25
database/connection.go Normal file
View File

@@ -0,0 +1,25 @@
package database
import (
"os"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
var DB *gorm.DB
var err error
func CreateConnection() {
DB, err = gorm.Open(postgres.Open(os.Getenv("DATABASE_URL")), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
DB.AutoMigrate(
&Quote{},
&QuoteLine{},
&Image{},
&Admincard{},
&Splash{})
}

View File

@@ -3,27 +3,37 @@ package database
import (
"time"
"gorm.io/gorm"
"github.com/lib/pq"
)
type Quote struct {
gorm.Model
ID string `gorm:"primaryKey"`
date time.Time
tags []string
Date *time.Time
Tags pq.StringArray `gorm:"type:varchar(64)[]"`
}
type QuoteLine struct {
gorm.Model
author string
content string
Author string
Content string
}
type Image struct {
gorm.Model
id string
title string
description string
date time.Time
place string
link string
Id string
Title string
Description string
Date *time.Time
Place string
Link string
}
type Admincard struct {
Id string
Name string
Desc string
Img string
DevBadge bool
AssignedUser string
}
type Splash struct {
Id string
Splash string
}