Documentation ¶
Index ¶
- Variables
- func IntDateTime(i interface{}) int64
- func MapInterface(i interface{}) map[string]interface{}
- func SetContext(ctx context.Context, timeout time.Duration) (context.Context, context.CancelFunc)
- func SliceInterface(i interface{}) []interface{}
- func Unmarshal(s string) bson.M
- type Client
- func (client Client) Aggregate(ctx context.Context, colname string, pipeline []interface{}) ([]bson.M, error)
- func (client Client) DeleteMany(ctx context.Context, colname string, filter interface{}) (int64, error)
- func (client Client) DeleteOne(ctx context.Context, colname string, filter interface{}) (int64, error)
- func (client Client) FSget(filename string) (io.ReadSeeker, error)
- func (client Client) FSlist(transactionCtx context.Context, filter bson.M, sort string, order int64, ...) ([]bson.M, error)
- func (client Client) FSset(filename string) (int, error)
- func (client Client) Find(ctx context.Context, colname string, filter map[string]interface{}, ...) ([]bson.M, error)
- func (client Client) FindOne(ctx context.Context, colname string, filter map[string]interface{}, ...) (*mongo.SingleResult, error)
- func (client Client) InsertMany(ctx context.Context, colname string, docs []interface{}, ordered bool) (int, []interface{}, error)
- func (client Client) InsertOne(ctx context.Context, colname string, doc interface{}) (interface{}, error)
- func (client Client) ReplaceOne(ctx context.Context, colname string, filter interface{}, replace interface{}, ...) (int64, error)
- func (client Client) Transaction(actions []map[string]interface{}, timeout int) (interface{}, error)
- func (client Client) UpdateMany(ctx context.Context, colname string, filter interface{}, update interface{}) (int64, error)
- func (client Client) UpdateOne(ctx context.Context, colname string, filter interface{}, update interface{}, ...) (int64, error)
Constants ¶
This section is empty.
Variables ¶
var A primitive.A
A - re-export primitive.A
var DateTime primitive.DateTime
DateTime - re-export primitive.DateTime
var M primitive.M
M - re-export primitive.M
var Operations = []string{
"updateOne",
"insertOne",
"insertMany",
"updateMany",
}
Operations - list of allowed operations for transactions
Functions ¶
func IntDateTime ¶
func IntDateTime(i interface{}) int64
IntDateTime - the purpose is to convert a primitive.DateTime to int64
func MapInterface ¶
func MapInterface(i interface{}) map[string]interface{}
MapInterface - the purpose is to convert a primitive.M to map[string]interface{}
func SetContext ¶
SetContext - helper to set deadline to context
func SliceInterface ¶
func SliceInterface(i interface{}) []interface{}
SliceInterface - the purpose is to convert a primitive.A to []interface{}
Types ¶
type Client ¶
type Client struct { URI string Db *mongo.Database Connection *mongo.Client // contains filtered or unexported fields }
Client - instance initiated by constructor
func (Client) Aggregate ¶
func (client Client) Aggregate(ctx context.Context, colname string, pipeline []interface{}) ([]bson.M, error)
Aggregate - function to aggregate docs in collection, ctx can be nil
func (Client) DeleteMany ¶
func (client Client) DeleteMany(ctx context.Context, colname string, filter interface{}) (int64, error)
DeleteMany - function to delete many docs in the collection, ctx can be nil
func (Client) DeleteOne ¶
func (client Client) DeleteOne(ctx context.Context, colname string, filter interface{}) (int64, error)
DeleteOne - function to delete a single doc in the collection, ctx can be nil
func (Client) FSget ¶
func (client Client) FSget(filename string) (io.ReadSeeker, error)
FSget - function to fetch the actual file content
func (Client) FSlist ¶
func (client Client) FSlist(transactionCtx context.Context, filter bson.M, sort string, order int64, skip int64, limit int64) ([]bson.M, error)
FSlist - function to fetch the list of files together with its metadata
func (Client) Find ¶
func (client Client) Find(ctx context.Context, colname string, filter map[string]interface{}, opt map[string]interface{}) ([]bson.M, error)
Find - function to find doc in collection, ctx can be nil
func (Client) FindOne ¶
func (client Client) FindOne(ctx context.Context, colname string, filter map[string]interface{}, opt map[string]interface{}) (*mongo.SingleResult, error)
FindOne - function to find first encountered doc in collection, ctx can be nil
func (Client) InsertMany ¶
func (client Client) InsertMany(ctx context.Context, colname string, docs []interface{}, ordered bool) ( int, []interface{}, error)
InsertMany - function to insert many docs into collection, ctx can be nil
func (Client) InsertOne ¶
func (client Client) InsertOne(ctx context.Context, colname string, doc interface{}) (interface{}, error)
InsertOne - function to insert a single doc into collection, ctx can be nil
func (Client) ReplaceOne ¶
func (client Client) ReplaceOne(ctx context.Context, colname string, filter interface{}, replace interface{}, opts *options.ReplaceOptions) (int64, error)
ReplaceOne - function to replace a single doc in the collection, ctx can be nil
func (Client) Transaction ¶
func (client Client) Transaction(actions []map[string]interface{}, timeout int) (interface{}, error)
Transaction - creates a transaction