Documentation ¶
Index ¶
- func Aggregate(m ModelMongodb, results interface{}, group bson.D, filter interface{}, ...) (err error)
- func CreateIndexes(m ModelMongodb) (err error)
- func Delete(m ModelMongodb) (err error)
- func Find(m ModelMongodb, filter interface{}, sort interface{}) (err error)
- func InsertMany(data []interface{}) (err error)
- func MongodbHasIndexes(indexView mongo.IndexView) (found bool)
- func Read(m ModelMongodb) (err error)
- func Save(m ModelMongodb) (err error)
- func Select(m ModelMongodb, results interface{}, filter interface{}, sort interface{}, ...) (err error)
- func SetDefaultConfig(host string, dbName string, user string, password string, ...) error
- type ModelBaseMongodb
- func (m *ModelBaseMongodb) GetClient() (mc *MongodbClient)
- func (m *ModelBaseMongodb) GetId() string
- func (m *ModelBaseMongodb) Indexes() (indexes []mongo.IndexModel)
- func (m *ModelBaseMongodb) SetClient(mc *MongodbClient)
- func (m *ModelBaseMongodb) SetCreatedAt(t time.Time)
- func (m *ModelBaseMongodb) SetId(id string)
- func (m *ModelBaseMongodb) SetUpdatedAt(t time.Time)
- type ModelMongodb
- type MongodbClient
- func (mc *MongodbClient) Aggregate(collection string, group bson.D, filter interface{}, sort interface{}, ...) error
- func (mc *MongodbClient) Collection(collection string) (*mongo.Collection, error)
- func (mc *MongodbClient) Connect() error
- func (mc *MongodbClient) CreateIndexes(collectionName string, indexModels []mongo.IndexModel) error
- func (mc *MongodbClient) Delete(collection string, filter interface{}, count *int64) (err error)
- func (mc *MongodbClient) Find(collection string, filter interface{}, sort interface{}, result interface{}) (err error)
- func (mc *MongodbClient) InsertMany(collectionName string, data []interface{}) (ids []string, err error)
- func (mc *MongodbClient) InsertOne(collectionName string, data interface{}) (id string, err error)
- func (mc *MongodbClient) Ping() error
- func (mc *MongodbClient) Select(collection string, filter interface{}, sort interface{}, limit int64, ...) (err error)
- func (mc *MongodbClient) Update(collectionName string, filter interface{}, update interface{}) (count int64, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Aggregate ¶
func Aggregate(m ModelMongodb, results interface{}, group bson.D, filter interface{}, sort interface{}) (err error)
func CreateIndexes ¶
func CreateIndexes(m ModelMongodb) (err error)
func Delete ¶
func Delete(m ModelMongodb) (err error)
func Find ¶
func Find(m ModelMongodb, filter interface{}, sort interface{}) (err error)
func InsertMany ¶
func InsertMany(data []interface{}) (err error)
func MongodbHasIndexes ¶
func Read ¶
func Read(m ModelMongodb) (err error)
func Save ¶
func Save(m ModelMongodb) (err error)
func Select ¶
func Select(m ModelMongodb, results interface{}, filter interface{}, sort interface{}, limit int64, offset int64, total *int64) (err error)
func SetDefaultConfig ¶
Types ¶
type ModelBaseMongodb ¶
type ModelBaseMongodb struct { Id string `json:"id,omitempty" bson:"_id"` CreatedAt string `json:"created_at" bson:"created_at"` UpdatedAt string `json:"updated_at" bson:"updated_at"` // contains filtered or unexported fields }
func (*ModelBaseMongodb) GetClient ¶
func (m *ModelBaseMongodb) GetClient() (mc *MongodbClient)
func (*ModelBaseMongodb) GetId ¶
func (m *ModelBaseMongodb) GetId() string
func (*ModelBaseMongodb) Indexes ¶
func (m *ModelBaseMongodb) Indexes() (indexes []mongo.IndexModel)
func (m *ModelBaseMongodb) CollectionName() string { return "" }
func (*ModelBaseMongodb) SetClient ¶
func (m *ModelBaseMongodb) SetClient(mc *MongodbClient)
func (*ModelBaseMongodb) SetCreatedAt ¶
func (m *ModelBaseMongodb) SetCreatedAt(t time.Time)
func (*ModelBaseMongodb) SetId ¶
func (m *ModelBaseMongodb) SetId(id string)
func (*ModelBaseMongodb) SetUpdatedAt ¶
func (m *ModelBaseMongodb) SetUpdatedAt(t time.Time)
type ModelMongodb ¶
type ModelMongodb interface { SetId(id string) GetId() string CollectionName() string Indexes() (indexes []mongo.IndexModel) SetClient(mc *MongodbClient) GetClient() (mc *MongodbClient) SetCreatedAt(t time.Time) SetUpdatedAt(t time.Time) }
type MongodbClient ¶
type MongodbClient struct { Host string DbName string User string Password string LoggerOptions *options.LoggerOptions // contains filtered or unexported fields }
func GetDefaultClient ¶
func GetDefaultClient() *MongodbClient
func NewMongodbClient ¶
func NewMongodbClient(host string, dbName string, user string, password string, loggerOptions ...*options.LoggerOptions) *MongodbClient
func (*MongodbClient) Aggregate ¶
func (mc *MongodbClient) Aggregate(collection string, group bson.D, filter interface{}, sort interface{}, results interface{}) error
func (*MongodbClient) Collection ¶
func (mc *MongodbClient) Collection(collection string) (*mongo.Collection, error)
func (*MongodbClient) Connect ¶
func (mc *MongodbClient) Connect() error
func (*MongodbClient) CreateIndexes ¶
func (mc *MongodbClient) CreateIndexes(collectionName string, indexModels []mongo.IndexModel) error
func (*MongodbClient) Delete ¶
func (mc *MongodbClient) Delete(collection string, filter interface{}, count *int64) (err error)
func (*MongodbClient) Find ¶
func (mc *MongodbClient) Find(collection string, filter interface{}, sort interface{}, result interface{}) (err error)
func (*MongodbClient) InsertMany ¶
func (mc *MongodbClient) InsertMany(collectionName string, data []interface{}) (ids []string, err error)
func (*MongodbClient) InsertOne ¶
func (mc *MongodbClient) InsertOne(collectionName string, data interface{}) (id string, err error)
func (*MongodbClient) Ping ¶
func (mc *MongodbClient) Ping() error
Click to show internal directories.
Click to hide internal directories.