Documentation ¶
Index ¶
- func Document(request interface{}) (doc bson.M, err error)
- type DB
- func (db *DB) Create(request interface{}, collection string) (err error)
- func (db *DB) CreateCollection(collection string) error
- func (db *DB) CreateMany(request []interface{}, collection string) (err error)
- func (db *DB) DecodeRaw(cursor *mg.Cursor) (documents []bson.Raw, err error)
- func (db *DB) Delete(collection string, identifier bson.M) (result *mg.DeleteResult, err error)
- func (db *DB) Find(collection string, filters bson.M, findOptions *options.FindOptions) (result []bson.Raw, err error)
- func (db *DB) FindOne(collection string, filters bson.M, findOptions *options.FindOneOptions) (result bson.Raw, err error)
- func (db *DB) Update(collection string, identifier bson.M, doc interface{}) (result *mg.UpdateResult, err error)
- type DBConn
- type MockDB
- func (db *MockDB) Create(request interface{}, collection string) (err error)
- func (db *MockDB) CreateCollection(collection string) error
- func (db *MockDB) CreateMany(request []interface{}, collection string) (err error)
- func (db *MockDB) Delete(collection string, identifier bson.M) (result *mg.DeleteResult, err error)
- func (db *MockDB) Find(collection string, filters bson.M, findOptions *options.FindOptions) (results []bson.Raw, err error)
- func (db *MockDB) FindOne(collection string, filters bson.M, findOptions *options.FindOneOptions) (result bson.Raw, err error)
- func (db *MockDB) Update(collection string, identifier bson.M, v interface{}) (result *mg.UpdateResult, err error)
- type MongoClient
- func (mongoClient *MongoClient) CreateCollection(collection string, options *options.CreateCollectionOptions) error
- func (mongoClient *MongoClient) CreateCollections(collections []string) error
- func (mongoClient *MongoClient) Delete(collection string, identifier bson.M) (*mongo.DeleteResult, error)
- func (mongoClient *MongoClient) Disconnect()
- func (mongoClient *MongoClient) Document(v interface{}) (doc *bson.D, err error)
- func (mongoClient *MongoClient) DropCollections(collections []string) error
- func (mongoClient *MongoClient) Find(collection string, filter bson.M, options *options.FindOptions) (*mongo.Cursor, error)
- func (mongoClient *MongoClient) FindOne(collection string, filter bson.M, options *options.FindOneOptions) *mongo.SingleResult
- func (mongoClient *MongoClient) GetMongoClient(clientUrl string) *mongo.Client
- func (mongoClient *MongoClient) Update(collection string, identifier bson.M, change bson.D) (*mongo.UpdateResult, error)
- func (mongoClient *MongoClient) Write(collection string, doc bson.D) (*mongo.InsertOneResult, error)
- func (mongoClient *MongoClient) WriteMany(collection string, doc []interface{}) (*mongo.InsertManyResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶ added in v0.1.5
type DB struct {
// contains filtered or unexported fields
}
func (*DB) CreateCollection ¶ added in v0.1.5
func (*DB) CreateMany ¶ added in v0.1.5
type DBConn ¶ added in v0.1.5
type DBConn interface { CreateCollection(collection string) error Create(request interface{}, collection string) (err error) CreateMany(request []interface{}, collection string) (err error) FindOne(collection string, filters bson.M, findOptions *options.FindOneOptions) (result bson.Raw, err error) Find(collection string, filters bson.M, findOptions *options.FindOptions) (result []bson.Raw, err error) Delete(collection string, identifier bson.M) (result *mg.DeleteResult, err error) Update(collection string, identifier bson.M, doc interface{}) (result *mg.UpdateResult, err error) }
type MockDB ¶ added in v0.1.6
type MockDB struct {
Data map[string]map[interface{}]interface{}
}
func (*MockDB) CreateCollection ¶ added in v0.1.6
func (*MockDB) CreateMany ¶ added in v0.1.6
type MongoClient ¶ added in v0.1.2
type MongoClient struct {
// contains filtered or unexported fields
}
func NewMongoClient ¶ added in v0.1.5
func NewMongoClient(url string, dbName string) *MongoClient
func (*MongoClient) CreateCollection ¶ added in v0.1.2
func (mongoClient *MongoClient) CreateCollection(collection string, options *options.CreateCollectionOptions) error
func (*MongoClient) CreateCollections ¶ added in v0.1.2
func (mongoClient *MongoClient) CreateCollections(collections []string) error
Creates collections with given names
func (*MongoClient) Delete ¶ added in v0.1.2
func (mongoClient *MongoClient) Delete(collection string, identifier bson.M) (*mongo.DeleteResult, error)
Deletes the documents from the specified database and collection based on identifier filter. Returns the id of the document upon delete if one entry or the count information if many. If delete fails, returns an error otherwise. Client must be configured to use this endpoint.
func (*MongoClient) Disconnect ¶ added in v0.1.2
func (mongoClient *MongoClient) Disconnect()
func (*MongoClient) Document ¶ added in v0.1.2
func (mongoClient *MongoClient) Document(v interface{}) (doc *bson.D, err error)
Converts a struct to the bson document used for inserting document.
func (*MongoClient) DropCollections ¶ added in v0.1.2
func (mongoClient *MongoClient) DropCollections(collections []string) error
Drops collections with given names
func (*MongoClient) Find ¶ added in v0.1.2
func (mongoClient *MongoClient) Find(collection string, filter bson.M, options *options.FindOptions) (*mongo.Cursor, error)
Finds a cursor of the documents based on the filter and filter options from the specified database and collection. Returns the documents upon search and error otherwise. Client must be configured to use this endpoint.
func (*MongoClient) FindOne ¶ added in v0.1.2
func (mongoClient *MongoClient) FindOne(collection string, filter bson.M, options *options.FindOneOptions) *mongo.SingleResult
Finds a document based on the filter from the specified database and collection. Client must be configured to use this endpoint.
func (*MongoClient) GetMongoClient ¶ added in v0.1.2
func (mongoClient *MongoClient) GetMongoClient(clientUrl string) *mongo.Client
Returns the db client of the attached client url.
func (*MongoClient) Update ¶ added in v0.1.2
func (mongoClient *MongoClient) Update(collection string, identifier bson.M, change bson.D) (*mongo.UpdateResult, error)
Updates the documents to the specified database and collection based on identifier filter. Returns the id of the document upon update if one entry or the count information if many. If update fails, returns an error otherwise. Client must be configured to use this endpoint.
func (*MongoClient) Write ¶ added in v0.1.2
func (mongoClient *MongoClient) Write(collection string, doc bson.D) (*mongo.InsertOneResult, error)
Inserts a document to the specified database and collection. Returns the id of the document upon creation and error otherwise. Client must be configured to use this endpoint.
func (*MongoClient) WriteMany ¶ added in v0.1.2
func (mongoClient *MongoClient) WriteMany(collection string, doc []interface{}) (*mongo.InsertManyResult, error)
Inserts many documents to the specified database and collection. Returns the id of the documents upon creation and error otherwise. Client must be configured to use this endpoint.