db

package
v0.0.0-...-3de21e0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ARANGO_ROOT_PASSWORD = os.Getenv("ARANGO_ROOT_PASSWORD")
	DB_PROTOCOL          = os.Getenv("DB_PROTOCOL")
	DB_HOST              = os.Getenv("DB_HOST")
	DB_PORT              = os.Getenv("DB_PORT")
	DB_NAME              = os.Getenv("DB_NAME")
	DB_COLLECTION        = os.Getenv("DB_COLLECTION")
)

required env vars for establishing the conn

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

main struct for the database

func (*DB) Authenticate

func (db *DB) Authenticate() error

func (*DB) CheckIfExists

func (db *DB) CheckIfExists(user User) (bool, *driver.DocumentMeta)

func (*DB) Connect

func (db *DB) Connect() error

func (*DB) Create

func (db *DB) Create(user User) *driver.DocumentMeta

create a record

func (*DB) Delete

func (db *DB) Delete(user User) *driver.DocumentMeta

delete record

func (*DB) DeleteDB

func (db *DB) DeleteDB() error

delete the whole db

func (*DB) Init

func (db *DB) Init()

func (*DB) InitializeCollection

func (db *DB) InitializeCollection(collectionName string) error

creates a collection if non-existant, initializes the driver.Collection

func (*DB) InitializeDatabase

func (db *DB) InitializeDatabase(dbName string) error

creates a database if non-existant, initializes the driver.Database

func (*DB) ReadAll

func (db *DB) ReadAll() []*User

read all records

func (*DB) ReadOne

func (db *DB) ReadOne(name string) (*User, *driver.DocumentMeta, error)

read one record by name

func (*DB) Update

func (db *DB) Update(user User) *driver.DocumentMeta

update record

func (*DB) UpdateMeta

func (db *DB) UpdateMeta(meta driver.DocumentMeta)

update the meta on the database struct

type User

type User struct {
	Name string `json:"name"`
	Age  int    `json:"age"`
}

Jump to

Keyboard shortcuts

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