Documentation ¶
Index ¶
- Constants
- type Db
- type Driver
- type Entity
- type MongoDbDriver
- func (mdd *MongoDbDriver) DeleteMany(table string, filter map[string]any) error
- func (mdd *MongoDbDriver) DeleteOne(e *Entity) error
- func (mdd *MongoDbDriver) GetMany(table string, params map[string]any) (ResultIterator, error)
- func (mdd *MongoDbDriver) GetOne(table string, params map[string]any) (*Entity, error)
- func (mdd *MongoDbDriver) InsertMany(entities []*Entity) error
- func (mdd *MongoDbDriver) InsertOne(e *Entity) error
- func (mdd *MongoDbDriver) UpdateMany(table string, filter map[string]any, update map[string]any) error
- func (mdd *MongoDbDriver) UpdateOne(e *Entity) error
- type MongoDbResultIterator
- type ResultIterator
Constants ¶
const FilteredDataTableName = "filtered_data"
const ScrapedDataTableName = "scraped_data"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Db ¶
type Db struct {
Driver
}
Db is a facade that holds an instance of Driver and forwards its functions, Driver is interchangeable and allows the changing of database types. Db currently does not support context.Context.
type Driver ¶
type Driver interface { GetOne(table string, params map[string]any) (*Entity, error) GetMany(table string, params map[string]any) (ResultIterator, error) InsertOne(e *Entity) error InsertMany(entities []*Entity) error UpdateOne(e *Entity) error UpdateMany(table string, filter map[string]any, update map[string]any) error DeleteOne(e *Entity) error DeleteMany(table string, filter map[string]any) error // contains filtered or unexported methods }
Driver holds functions to communicate with a database in a streamlined fashion, and is meant to be interchangeable so databases types can be easily switched if required. Driver currently does not support context.Context.
type Entity ¶
type Entity struct { Id any Table string Data map[string]any CreatedAt *time.Time UpdatedAt *time.Time }
Entity holds results from DB queries and is used to interact with Driver. All data should be stored in Data, however it maps Id, CreatedAt and UpdatedAt for ease of access.
type MongoDbDriver ¶
type MongoDbDriver struct {
// contains filtered or unexported fields
}
MongoDbDriver communicates with an instance of MongoDB and offers queries through the Driver interface. MongoDbDriver is currently not concurrency proof and does not cache any results.
func NewMongoDbDriver ¶
func NewMongoDbDriver() *MongoDbDriver
func (*MongoDbDriver) DeleteMany ¶
func (mdd *MongoDbDriver) DeleteMany(table string, filter map[string]any) error
DeleteMany deletes multiple rows within MongoDB based on the provided table and filter.
func (*MongoDbDriver) DeleteOne ¶
func (mdd *MongoDbDriver) DeleteOne(e *Entity) error
func (*MongoDbDriver) GetMany ¶
func (mdd *MongoDbDriver) GetMany(table string, params map[string]any) (ResultIterator, error)
func (*MongoDbDriver) InsertMany ¶
func (mdd *MongoDbDriver) InsertMany(entities []*Entity) error
func (*MongoDbDriver) InsertOne ¶
func (mdd *MongoDbDriver) InsertOne(e *Entity) error
func (*MongoDbDriver) UpdateMany ¶
func (mdd *MongoDbDriver) UpdateMany(table string, filter map[string]any, update map[string]any) error
UpdateMany updates multiple rows within MongoDB based on the provided filter and fields to be updated.
func (*MongoDbDriver) UpdateOne ¶
func (mdd *MongoDbDriver) UpdateOne(e *Entity) error
type MongoDbResultIterator ¶
type MongoDbResultIterator struct {
// contains filtered or unexported fields
}
func (*MongoDbResultIterator) Next ¶
func (mdri *MongoDbResultIterator) Next() (*Entity, error)