database

package
v0.0.0-...-4598f8e Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package database General database for CRUD operation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(db *gorm.DB, model interface{}) error

Create will create new record into model and save it to database

func DB

func DB() *gorm.DB

DB will return Database Connection

func DBErr

func DBErr() error

Return DB Error

func Delete

func Delete(db *gorm.DB, condition, model interface{}) (count int, err error)

Delete will delete record(s) from model with given condition it will returning 'count' of affected record and error status

func Find

func Find(db *gorm.DB, condition, model interface{}, associations []string) (
	isEmpty bool, err error)

Find will get model and its associations records based on given condition

func First

func First(db *gorm.DB, condition, model interface{}, associations []string) (
	isNotFound bool, err error)

First will fetch model and its associations based on given condition

func Save

func Save(db *gorm.DB, model interface{}) error

Save will save new record into model and save it to database

func Setup

func Setup() error

Init database and forward saved ref to the Database struct

func Update

func Update(db *gorm.DB, condition, model interface{}) error

Update will update model record into the database

Types

type Database

type Database struct {
	*gorm.DB
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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