Documentation ¶
Index ¶
- func CheckInsertError(e error) error
- func GetClient(moptions *MongoOptions) (*mongo.Client, error)
- func IDFromHex(id string) primitive.ObjectID
- func IDString(id primitive.ObjectID) string
- type Collection
- func (c *Collection[TEntity]) Col() *mongo.Collection
- func (c *Collection[TEntity]) Count(ctx context.Context, filter bson.D, opts ...*options.CountOptions) int64
- func (r *Collection[TEntity]) Delete(ctx context.Context, id primitive.ObjectID) int
- func (r *Collection[TEntity]) DeleteMany(ctx context.Context, ids []primitive.ObjectID) int
- func (r *Collection[TEntity]) Exists(ctx context.Context, id primitive.ObjectID) bool
- func (r *Collection[TEntity]) ExistsByFilter(ctx context.Context, filter bson.D) bool
- func (c *Collection[TEntity]) Find(ctx context.Context, filter bson.D, opts ...*options.FindOptions) []TEntity
- func (c *Collection[TEntity]) FindOne(ctx context.Context, filter bson.D, opts ...*options.FindOneOptions) *TEntity
- func (r *Collection[TEntity]) Get(ctx context.Context, id primitive.ObjectID) *TEntity
- func (r *Collection[TEntity]) GetList(ctx context.Context, filter bson.D, page int64, pageSize int64, ...) ([]TEntity, int64)
- func (r *Collection[TEntity]) GetMany(ctx context.Context, ids []primitive.ObjectID, filter bson.D) []TEntity
- func (r *Collection[TEntity]) Insert(ctx context.Context, entity *TEntity) primitive.ObjectID
- func (r *Collection[TEntity]) InsertMany(ctx context.Context, entitis []TEntity, ignoreErr bool) []primitive.ObjectID
- func (r *Collection[TEntity]) UpdateByID(ctx context.Context, id primitive.ObjectID, entity *TEntity) int
- func (r *Collection[TEntity]) UpdateOne(ctx context.Context, filter bson.D, entity *TEntity, ...) int
- type Decimal
- type MongoOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckInsertError ¶
Types ¶
type Collection ¶
type Collection[TEntity any] struct { // contains filtered or unexported fields }
func NewCollection ¶
func NewCollection[TEntity any](c *mongo.Collection) *Collection[TEntity]
func (*Collection[TEntity]) Col ¶
func (c *Collection[TEntity]) Col() *mongo.Collection
func (*Collection[TEntity]) Count ¶
func (c *Collection[TEntity]) Count(ctx context.Context, filter bson.D, opts ...*options.CountOptions) int64
func (*Collection[TEntity]) DeleteMany ¶
func (*Collection[TEntity]) ExistsByFilter ¶
func (*Collection[TEntity]) Find ¶
func (c *Collection[TEntity]) Find(ctx context.Context, filter bson.D, opts ...*options.FindOptions) []TEntity
func (*Collection[TEntity]) FindOne ¶
func (c *Collection[TEntity]) FindOne(ctx context.Context, filter bson.D, opts ...*options.FindOneOptions) *TEntity
func (*Collection[TEntity]) Get ¶
func (r *Collection[TEntity]) Get(ctx context.Context, id primitive.ObjectID) *TEntity
func (*Collection[TEntity]) GetList ¶
func (r *Collection[TEntity]) GetList(ctx context.Context, filter bson.D, page int64, pageSize int64, opt *options.FindOptions) ([]TEntity, int64)
func (*Collection[TEntity]) Insert ¶
func (r *Collection[TEntity]) Insert(ctx context.Context, entity *TEntity) primitive.ObjectID
func (*Collection[TEntity]) InsertMany ¶
func (*Collection[TEntity]) UpdateByID ¶
func (*Collection[TEntity]) UpdateOne ¶
func (r *Collection[TEntity]) UpdateOne(ctx context.Context, filter bson.D, entity *TEntity, opts ...*options.UpdateOptions) int
type Decimal ¶
func (Decimal) DecodeValue ¶
func (d Decimal) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error
func (Decimal) EncodeValue ¶
func (d Decimal) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error
type MongoOptions ¶
Click to show internal directories.
Click to hide internal directories.