Documentation ¶
Index ¶
- func DefaultContext() context.Context
- type BeforeInsertHook
- type BeforeUpdateHook
- type Collection
- func (repo *Collection[T]) Aggregate(pipeline mongo.Pipeline, opts ...*options.AggregateOptions) ([]bson.M, error)
- func (repo *Collection[T]) CountDocuments(filter interface{}) (int64, error)
- func (repo *Collection[T]) CreateIndex(keys bson.D) error
- func (repo *Collection[T]) DeleteById(id string) error
- func (repo *Collection[T]) Drop() error
- func (repo *Collection[T]) Find(filter interface{}, opts ...*options.FindOptions) ([]T, error)
- func (repo *Collection[T]) FindById(id interface{}) (T, error)
- func (repo *Collection[T]) FindOne(filter interface{}) (T, error)
- func (repo *Collection[T]) Insert(model T) (T, error)
- func (repo *Collection[T]) NewId() primitive.ObjectID
- func (repo *Collection[T]) UpdateById(id string, model T) error
- func (repo *Collection[T]) UpdateMany(filter interface{}, doc bson.M) error
- func (repo *Collection[T]) UpdateOne(filter interface{}, model T) error
- type Database
- type Doc
- type DocWithTimestamps
- type Document
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultContext ¶
Types ¶
type BeforeInsertHook ¶
type BeforeInsertHook interface {
BeforeInsert() error
}
type BeforeUpdateHook ¶ added in v0.0.3
type BeforeUpdateHook interface {
BeforeUpdate() error
}
type Collection ¶
type Collection[T Document] struct { // contains filtered or unexported fields }
func GetCollection ¶
func GetCollection[T Document](db *Database, collectionName string) *Collection[T]
func (*Collection[T]) Aggregate ¶ added in v0.0.14
func (repo *Collection[T]) Aggregate(pipeline mongo.Pipeline, opts ...*options.AggregateOptions) ([]bson.M, error)
func (*Collection[T]) CountDocuments ¶
func (repo *Collection[T]) CountDocuments(filter interface{}) (int64, error)
func (*Collection[T]) CreateIndex ¶
func (repo *Collection[T]) CreateIndex(keys bson.D) error
func (*Collection[T]) DeleteById ¶
func (repo *Collection[T]) DeleteById(id string) error
func (*Collection[T]) Drop ¶ added in v0.0.14
func (repo *Collection[T]) Drop() error
func (*Collection[T]) Find ¶
func (repo *Collection[T]) Find(filter interface{}, opts ...*options.FindOptions) ([]T, error)
func (*Collection[T]) FindById ¶
func (repo *Collection[T]) FindById(id interface{}) (T, error)
func (*Collection[T]) FindOne ¶
func (repo *Collection[T]) FindOne(filter interface{}) (T, error)
func (*Collection[T]) Insert ¶
func (repo *Collection[T]) Insert(model T) (T, error)
func (*Collection[T]) NewId ¶
func (repo *Collection[T]) NewId() primitive.ObjectID
func (*Collection[T]) UpdateById ¶
func (repo *Collection[T]) UpdateById(id string, model T) error
func (*Collection[T]) UpdateMany ¶
func (repo *Collection[T]) UpdateMany(filter interface{}, doc bson.M) error
func (*Collection[T]) UpdateOne ¶
func (repo *Collection[T]) UpdateOne(filter interface{}, model T) error
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func (*Database) Disconnect ¶ added in v0.0.8
type DocWithTimestamps ¶
type DocWithTimestamps struct { Doc `bson:",inline"` CreatedAt time.Time `json:"created_at" bson:"created_at"` UpdatedAt *time.Time `json:"updated_at,omitempty" bson:"updated_at,omitempty"` }
func (*DocWithTimestamps) BeforeInsert ¶
func (doc *DocWithTimestamps) BeforeInsert() error
func (*DocWithTimestamps) BeforeUpdate ¶
func (doc *DocWithTimestamps) BeforeUpdate() error
Click to show internal directories.
Click to hide internal directories.