Documentation ¶
Index ¶
- func Scan(structMap map[string]any, fields []string, scan ScanFunc) error
- type InMemoryKV
- type Model
- type MongoDB
- func (m *MongoDB[T]) All(ctx context.Context, collectionName string, opts *options.FindOptions) ([]T, error)
- func (m *MongoDB[T]) Count(ctx context.Context, collectionName string) (int64, error)
- func (m *MongoDB[T]) Delete(ctx context.Context, collectionName string, filter bson.D, ...) error
- func (m *MongoDB[T]) Drop(ctx context.Context, collectionName string) error
- func (m *MongoDB[T]) FindByID(ctx context.Context, collectionName string, id uuid.UUID) (T, error)
- func (m *MongoDB[T]) Insert(ctx context.Context, collectionName string, document T) error
- func (m *MongoDB[T]) Search(ctx context.Context, collectionName string, filter bson.D, ...) ([]T, error)
- func (m *MongoDB[T]) Update(ctx context.Context, collectionName string, id uuid.UUID, document T) (*mongo.UpdateResult, error)
- type PosgresDB
- func (p PosgresDB[M]) All(ctx context.Context) (*structures.Array[M], error)
- func (p PosgresDB[M]) Create(ctx context.Context, m M) (any, error)
- func (p PosgresDB[M]) Delete(ctx context.Context, m M) error
- func (p PosgresDB[M]) Get(ctx context.Context, opts ...query.Option) (M, bool, error)
- func (p PosgresDB[M]) Select(ctx context.Context, cols []string, opts ...query.Option) (*structures.Array[M], error)
- func (p PosgresDB[M]) Update(ctx context.Context, m M) error
- type ScanFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type InMemoryKV ¶
func NewInMemoryKV ¶
func NewInMemoryKV[K int, V any]() *InMemoryKV[K, V]
func (*InMemoryKV[K, V]) Delete ¶
func (kv *InMemoryKV[K, V]) Delete(key K) error
func (*InMemoryKV[K, V]) Get ¶
func (kv *InMemoryKV[K, V]) Get(key K) (V, error)
func (*InMemoryKV[K, V]) Set ¶
func (kv *InMemoryKV[K, V]) Set(key K, val V) error
type Model ¶
type Model interface { // Primary returns the name of the column used as the primary key for the Model, and the value for that column if any. Primary() (string, any) // Scan the given fields using the ScanFunc. Scan(fields []string, scan ScanFunc) error // Params return the parameters of the Model to be used during create and update operations. Params() map[string]any }
type MongoDB ¶
func NewMongoDB ¶
NewMongoDB takes an env file and returns mongo client
type PosgresDB ¶
func NewPostgresDB ¶
NewPostgresDB takes a .env config file, table name and new func. .env file example
POSTGRES_HOST=postgres POSTGRES_PORT=5432 POSTGRES_USERNAME=postgres POSTGRES_PASSWORD=changeme
Click to show internal directories.
Click to hide internal directories.