models

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteCache

func DeleteCache(c *cache.Cache, key string)

Delete cache

func FlushCache

func FlushCache(c *cache.Cache)

Flush cache - Deletes all the keys

func GetCache

func GetCache(c *cache.Cache, key string) (interface{}, bool)

Get cache

func SetCache

func SetCache(c *cache.Cache, key string, value interface{})

Set cache

func StartCache

func StartCache(expiration int, purge int) *cache.Cache

This function would cache the data for a specified time provided by the user. Start cache

Types

type Driver

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

func New

func New(dir string) (*Driver, *cache.Cache, error)

CREATE A NEW DATABASE (COLLECTION)

func (*Driver) Delete

func (driver *Driver) Delete(collection string, data string) error

DELETE ANY RECORD FROM A GIVEN COLLECTION

func (*Driver) DeleteCollection

func (driver *Driver) DeleteCollection(collection string) error

Delete any collection (All records in that collection)

func (*Driver) ManageMutex

func (driver *Driver) ManageMutex(collection string) *sync.Mutex

MANAGE MUTEXES FOR EACH COLLECTION

func (*Driver) Read

func (driver *Driver) Read(collection string, data string, c *cache.Cache, wantCache bool) (string, error)

READ ANY RECORD FROM A GIVEN COLLECTION Only From Primary Key

func (*Driver) ReadAll

func (driver *Driver) ReadAll(collection string, c *cache.Cache, wantCache bool) ([]string, error)

READ ALL RECORDS FROM A GIVEN COLLECTION THIS WILL RETURN JSON ARRAY OF ALL THE RECORDS

func (*Driver) Search

func (driver *Driver) Search(collection string, searchField string, value string) error

TO CHECK IF IT WORKS IN NESTED STRUCTS(JSON) - Add to experimental maybe? ALSO THIS VALUE IS JUST PRINTED NOT RETURNED ( TO FIX) ADD Search by other values except primary key

func (*Driver) Update

func (driver *Driver) Update(collection string, data string, v interface{}, newValues map[string]interface{}) error

Update with only the required fields, TO COMPLETE

func (*Driver) UpdateRecord

func (driver *Driver) UpdateRecord(collection string, data string, v interface{}) error

Update any record from a given collection Currently we have to enter the entire User struct, UPDATE IT SO THAT WE CAN UPDATE ONLY THE REQUIRED FIELDS(Or Maybe make a new method for that?) Only Primary Key

func (*Driver) Write

func (driver *Driver) Write(collection string, v interface{}) error

WRITE ANY RECORD TO A GIVEN COLLECTION

Jump to

Keyboard shortcuts

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