models

package
v0.0.0-...-778fa5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToBDD

func ConnectToBDD() (*gorm.DB, error)

Make connexion with database Use this function before making database request Example of use db, err := ConnectToBDD()

if err != nil {
	return "what you want"
}

defer db.Close()

func CreateArticle

func CreateArticle(article Article) (int, error)

Create an article or error

func EditArticle

func EditArticle(article Article, newArticle Article) error

Edit an article or error

Types

type Article

type Article struct {
	ID          int
	Title       string
	Description string
}

Structure of an article in db

func AddArticleItem

func AddArticleItem(articles []Article, id int, title string, description string) []Article

Add Article to []Article

func EmptyArticles

func EmptyArticles() []Article

Init empty []Article

func GetArticle

func GetArticle(id int) (Article, error)

Get one article by id or error

func GetArticles

func GetArticles() ([]Article, error)

Get all articles or error

func InitArticles

func InitArticles(id int, title string, description string) []Article

Init []Article

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL