Documentation ¶
Overview ¶
Package easymongo provides a simple and easy-to-use wrapper for MongoDB operations in Go.
Index ¶
- type MongoInstance
- func (m *MongoInstance) Close()
- func (m *MongoInstance) DeleteOne(filter bson.D) (*mongo.DeleteResult, error)
- func (m *MongoInstance) FindOne(filter bson.D) *mongo.SingleResult
- func (m *MongoInstance) InsertMany(documents []interface{}) (*mongo.InsertManyResult, error)
- func (m *MongoInstance) InsertOne(document interface{}) (*mongo.InsertOneResult, error)
- func (m *MongoInstance) UpdateOne(filter bson.D, update bson.D) (*mongo.UpdateResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MongoInstance ¶
type MongoInstance struct {
// contains filtered or unexported fields
}
MongoInstance represents a MongoDB connection instance.
func New ¶
func New(uri string, db string, collection string) *MongoInstance
New creates and returns a new instance of MongoInstance.
func NewStatic ¶
func NewStatic(uri string, db string, collection string) *MongoInstance
NewStatic returns a singleton instance of MongoInstance.
func (*MongoInstance) DeleteOne ¶
func (m *MongoInstance) DeleteOne(filter bson.D) (*mongo.DeleteResult, error)
DeleteOne deletes a single document from the MongoDB collection based on the specified filter.
func (*MongoInstance) FindOne ¶
func (m *MongoInstance) FindOne(filter bson.D) *mongo.SingleResult
FindOne retrieves a single document from the MongoDB collection based on the specified filter.
func (*MongoInstance) InsertMany ¶
func (m *MongoInstance) InsertMany(documents []interface{}) (*mongo.InsertManyResult, error)
InsertMany inserts multiple documents into the MongoDB collection.
func (*MongoInstance) InsertOne ¶
func (m *MongoInstance) InsertOne(document interface{}) (*mongo.InsertOneResult, error)
InsertOne inserts a single document into the MongoDB collection.
func (*MongoInstance) UpdateOne ¶
func (m *MongoInstance) UpdateOne(filter bson.D, update bson.D) (*mongo.UpdateResult, error)
UpdateOne updates a single document in the MongoDB collection based on the specified filter and update.