Documentation ¶
Overview ¶
Code generated by db/gen/gen.go; DO NOT EDIT.
Index ¶
- Constants
- func Match(err error, codes ...int) bool
- type DB
- type DBError
- type GeoSpatial
- type MongoTransaction
- type Options
- type UserModel
- func (model *UserModel) Aggregate(pipeline interface{}, opts ...*options.AggregateOptions) ([]UserModel, error)
- func (model *UserModel) AggregateStream(pipeline interface{}, resultChan ..., opts ...*options.AggregateOptions)
- func (model *UserModel) BulkWrite(models []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)
- func (model UserModel) CreatedAtTag() string
- func (model *UserModel) DeleteMany(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (model *UserModel) DeleteManyTxn(sc mongo.SessionContext, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (model *UserModel) DeleteOne(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (model *UserModel) DeleteOneTxn(sc mongo.SessionContext, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (model UserModel) DeletedAtTag() string
- func (model *UserModel) Distinct(fieldName string, query interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)
- func (model *UserModel) Find(query interface{}, opts ...*options.FindOptions) ([]*UserModel, error)
- func (model *UserModel) FindOne(query interface{}, opts ...*options.FindOneOptions) (*UserModel, error)
- func (model *UserModel) FindOneAndUpdate(query interface{}, value interface{}, ...) (*UserModel, error)
- func (model *UserModel) FindOneAndUpdateTxn(sc mongo.SessionContext, query interface{}, value interface{}, ...) (*UserModel, error)
- func (model *UserModel) FindOneTxn(sc mongo.SessionContext, query interface{}, opts ...*options.FindOneOptions) (*UserModel, error)
- func (model *UserModel) FindStream(query interface{}, result ..., opts ...*options.FindOptions)
- func (model *UserModel) GetCollectionName() string
- func (model UserModel) IDTag() string
- func (model *UserModel) InsertOne(value UserModel, opts ...*options.InsertOneOptions) (primitive.ObjectID, error)
- func (model *UserModel) InsertOneTxn(sc mongo.SessionContext, value UserModel, opts ...*options.InsertOneOptions) (primitive.ObjectID, error)
- func (model *UserModel) SetUpdatedAt()
- func (model *UserModel) UpdateMany(query interface{}, value interface{}, options ...*options.UpdateOptions) (*mongo.UpdateResult, error)
- func (model *UserModel) UpdateManyTxn(sc mongo.SessionContext, query interface{}, value interface{}, ...) (*mongo.UpdateResult, error)
- func (model *UserModel) UpdateOne(query interface{}, value interface{}, options ...*options.UpdateOptions) (*mongo.UpdateResult, error)
- func (model *UserModel) UpdateOneTxn(sc mongo.SessionContext, query interface{}, value interface{}, ...) (*mongo.UpdateResult, error)
- func (model UserModel) UpdatedAtTag() string
- func (model UserModel) UserIDTag() string
- func (model *UserModel) Watch(ctx context.Context, pipeline interface{}, ...) (*mongo.ChangeStream, error)
Constants ¶
const ( // OK is for all OK OK = 0 // UnknownError - errors that is not classified UnknownError = 2 // NoMatchingDocument - error for no documents NoMatchingDocument = 47 // DuplicateKey - Duplicate key DuplicateKey = 11000 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DBError ¶
type DBError struct { Msg string Code int WriteErrors []mongo.WriteError }
DBError - Database errors
func ParseError ¶
ParseError - Parse db error from Error message
func (*DBError) IsNoMatchingDocError ¶
type GeoSpatial ¶
type GeoSpatial struct { Type string `bson:"type"` Coordinates []float64 `bson:"coordinates"` Location string `bson:"-"` }
GeoSpatial - For location coordinates
func NewGeoPoint ¶
func NewGeoPoint(longitude, latitude float64) *GeoSpatial
NewGeoPoint - Create a geo point
func (GeoSpatial) GetLatitude ¶
func (t GeoSpatial) GetLatitude() float64
GetLatitude - to get longitude from geo spatial coordinate
func (GeoSpatial) GetLongitude ¶
func (t GeoSpatial) GetLongitude() float64
GetLongitude - to get longitude from geo spatial coordinate
type MongoTransaction ¶
type MongoTransaction struct { Cancel context.CancelFunc Session mongo.Session SessionContext mongo.SessionContext // contains filtered or unexported fields }
MongoTransaction -
func NewTransaction ¶
func NewTransaction(client *mongo.Client) (*MongoTransaction, error)
NewTransaction - Start mongo transaction
func (*MongoTransaction) AbortTransaction ¶
func (t *MongoTransaction) AbortTransaction() error
AbortTransaction -
func (*MongoTransaction) CommitOrAbort ¶
func (t *MongoTransaction) CommitOrAbort() error
CommitOrAbort -
func (*MongoTransaction) CommitTransaction ¶
func (t *MongoTransaction) CommitTransaction() error
CommitTransaction -
type UserModel ¶
type UserModel struct { ID *primitive.ObjectID `bson:"_id,omitempty"` UserID *primitive.ObjectID `bson:"user_id,omitempty"` // fields DeletedAt *time.Time `bson:"deleted_at,omitempty"` UpdatedAt *time.Time `bson:"updated_at,omitempty"` CreatedAt *time.Time `bson:"created_at,omitempty"` // contains filtered or unexported fields }
UserModel is the model for base table
func (*UserModel) Aggregate ¶
func (model *UserModel) Aggregate(pipeline interface{}, opts ...*options.AggregateOptions) ([]UserModel, error)
Aggregate - mongodb aggregate
func (*UserModel) AggregateStream ¶
func (model *UserModel) AggregateStream(pipeline interface{}, resultChan chan<- struct { Val UserModel Err error }, opts ...*options.AggregateOptions)
Aggregate - mongodb aggregate
func (*UserModel) BulkWrite ¶
func (model *UserModel) BulkWrite(models []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)
func (UserModel) CreatedAtTag ¶
func (*UserModel) DeleteMany ¶
func (model *UserModel) DeleteMany(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteMany -
func (*UserModel) DeleteManyTxn ¶
func (model *UserModel) DeleteManyTxn(sc mongo.SessionContext, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteOneTxn - to DeleteOne
func (*UserModel) DeleteOne ¶
func (model *UserModel) DeleteOne(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteOne - to DeleteOne
func (*UserModel) DeleteOneTxn ¶
func (model *UserModel) DeleteOneTxn(sc mongo.SessionContext, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteOneTxn - to DeleteOne
func (UserModel) DeletedAtTag ¶
func (*UserModel) Distinct ¶
func (model *UserModel) Distinct(fieldName string, query interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)
func (*UserModel) Find ¶
func (model *UserModel) Find(query interface{}, opts ...*options.FindOptions) ([]*UserModel, error)
Find - to find
func (*UserModel) FindOne ¶
func (model *UserModel) FindOne(query interface{}, opts ...*options.FindOneOptions) (*UserModel, error)
FindOne - to findOne
func (*UserModel) FindOneAndUpdate ¶
func (model *UserModel) FindOneAndUpdate(query interface{}, value interface{}, options ...*options.FindOneAndUpdateOptions) (*UserModel, error)
FindOneAndUpdate -
func (*UserModel) FindOneAndUpdateTxn ¶
func (model *UserModel) FindOneAndUpdateTxn(sc mongo.SessionContext, query interface{}, value interface{}, options ...*options.FindOneAndUpdateOptions) (*UserModel, error)
FindOneAndUpdateTxn -
func (*UserModel) FindOneTxn ¶
func (model *UserModel) FindOneTxn(sc mongo.SessionContext, query interface{}, opts ...*options.FindOneOptions) (*UserModel, error)
FindOne - to findOne
func (*UserModel) FindStream ¶
func (model *UserModel) FindStream(query interface{}, result chan<- struct { Val UserModel Err error }, opts ...*options.FindOptions)
Find - to find
func (*UserModel) GetCollectionName ¶
GetCollectionName - get collection name
func (*UserModel) InsertOne ¶
func (model *UserModel) InsertOne(value UserModel, opts ...*options.InsertOneOptions) (primitive.ObjectID, error)
InsertOne -
func (*UserModel) InsertOneTxn ¶
func (model *UserModel) InsertOneTxn(sc mongo.SessionContext, value UserModel, opts ...*options.InsertOneOptions) (primitive.ObjectID, error)
InsertOneTxn -
func (*UserModel) SetUpdatedAt ¶
func (model *UserModel) SetUpdatedAt()
SetUpdatedAt - Set updated at
func (*UserModel) UpdateMany ¶
func (model *UserModel) UpdateMany(query interface{}, value interface{}, options ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateMany -
func (*UserModel) UpdateManyTxn ¶
func (model *UserModel) UpdateManyTxn(sc mongo.SessionContext, query interface{}, value interface{}, options ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateManyTxn -
func (*UserModel) UpdateOne ¶
func (model *UserModel) UpdateOne(query interface{}, value interface{}, options ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateOne -
func (*UserModel) UpdateOneTxn ¶
func (model *UserModel) UpdateOneTxn(sc mongo.SessionContext, query interface{}, value interface{}, options ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateOneTxn -
func (UserModel) UpdatedAtTag ¶
func (*UserModel) Watch ¶
func (model *UserModel) Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)