Documentation
¶
Index ¶
- func Aggregate[T any](c *Client, collName string, pipline mongo.Pipeline) chan ReadManyResult[T]
- func BulkWrite(c *Client, collName string, writeModels []mongo.WriteModel, ...) chan BulkWriteResult
- func CountDocuments(c *Client, collName string, filter any, ...) chan CountResult
- func CreateIndex(c *Client, collName string, indexDef any, opt *options.IndexOptionsBuilder) chan IndexCreateResult
- func DeleteMany(c *Client, collName string, filter any, ...) chan DeleteResult
- func DeleteOne(c *Client, collName string, filter any, ...) chan DeleteResult
- func Distinct[T any](c *Client, collName string, fieldName string, filter any, ...) chan DistinctResult[T]
- func DropAllIndex(c *Client, collName string, opts ...options.Lister[options.DropIndexesOptions]) chan IndexDropResult
- func DropIndex(c *Client, collName string, indexName string, ...) chan IndexDropResult
- func Find[T any](c *Client, collName string, filter any, ...) chan ReadManyResult[T]
- func FindOne[T any](c *Client, collName string, filter any, ...) chan ReadOneResult[T]
- func FindStream[T any](c *Client, collName string, filter any, ...) chan ReadStreamResult[T]
- func InsertMany[T any](c *Client, collName string, documents []T, ...) chan WriteManyResult
- func InsertOne(c *Client, collName string, document any, ...) chan WriteOneResult
- func ReplaceOne(c *Client, collName string, filter any, document any, ...) chan UpdateResult
- func RunCommand(c *Client, cmd any, opts ...options.Lister[options.RunCmdOptions]) chan CommandResult
- func UpdateMany(c *Client, collName string, filter any, instruction any, ...) chan UpdateResult
- func UpdateOne(c *Client, collName string, filter any, instruction any, ...) chan UpdateResult
- type BulkWriteResult
- type Client
- type CommandResult
- type CountResult
- type DeleteResult
- type DistinctResult
- type IndexCreateResult
- type IndexDropResult
- type IndexListResult
- type ReadManyResult
- type ReadOneResult
- type ReadStreamResult
- type TransactionFunc
- type TransactionResult
- type UpdateResult
- type WriteManyResult
- type WriteOneResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BulkWrite ¶
func BulkWrite(c *Client, collName string, writeModels []mongo.WriteModel, opts ...options.Lister[options.BulkWriteOptions]) chan BulkWriteResult
func CountDocuments ¶
func CountDocuments(c *Client, collName string, filter any, opts ...options.Lister[options.CountOptions]) chan CountResult
CountDocuments async, count the documents that return from the filter
func CreateIndex ¶
func CreateIndex(c *Client, collName string, indexDef any, opt *options.IndexOptionsBuilder) chan IndexCreateResult
func DeleteMany ¶
func DeleteMany(c *Client, collName string, filter any, opts ...options.Lister[options.DeleteManyOptions]) chan DeleteResult
DeleteMany delete many documents from a collection. work in async way. you need to check the result of the channel for options and details mongo deleteon command see: [https://www.mongodb.com/docs/drivers/go/current/usage-examples/deleteOne/]
func DeleteOne ¶
func DeleteOne(c *Client, collName string, filter any, opts ...options.Lister[options.DeleteOneOptions]) chan DeleteResult
DeleteOne delete on document in a async way for options and details mongo deleteon command see: [https://www.mongodb.com/docs/drivers/go/current/usage-examples/deleteOne/]
func Distinct ¶
func Distinct[T any](c *Client, collName string, fieldName string, filter any, opts ...options.Lister[options.DistinctOptions]) chan DistinctResult[T]
Distinct query for documents in async way
func DropAllIndex ¶
func DropAllIndex(c *Client, collName string, opts ...options.Lister[options.DropIndexesOptions]) chan IndexDropResult
func DropIndex ¶
func DropIndex(c *Client, collName string, indexName string, opts ...options.Lister[options.DropIndexesOptions]) chan IndexDropResult
func Find ¶
func Find[T any](c *Client, collName string, filter any, opts ...options.Lister[options.FindOptions]) chan ReadManyResult[T]
Find query for documents in async way
func FindOne ¶
func FindOne[T any](c *Client, collName string, filter any, opts ...options.Lister[options.FindOneOptions]) chan ReadOneResult[T]
FindOne async function that search for a single document in a collection
func FindStream ¶
func FindStream[T any](c *Client, collName string, filter any, opts ...options.Lister[options.FindOptions]) chan ReadStreamResult[T]
Find query for documents in async way
func InsertMany ¶
func InsertMany[T any](c *Client, collName string, documents []T, opts ...options.Lister[options.InsertManyOptions]) chan WriteManyResult
InsertMany insert many document in async way
func InsertOne ¶
func InsertOne(c *Client, collName string, document any, opts ...options.Lister[options.InsertOneOptions]) chan WriteOneResult
func ReplaceOne ¶
func ReplaceOne(c *Client, collName string, filter any, document any, opts ...options.Lister[options.ReplaceOptions]) chan UpdateResult
Update update a single document in an async way
func RunCommand ¶
func RunCommand(c *Client, cmd any, opts ...options.Lister[options.RunCmdOptions]) chan CommandResult
RunCommand run database command async
func UpdateMany ¶
func UpdateMany(c *Client, collName string, filter any, instruction any, opts ...options.Lister[options.UpdateManyOptions]) chan UpdateResult
Update update all documents matching the filter creteria in an async way
Types ¶
type BulkWriteResult ¶
type BulkWriteResult struct {
Err error
DbRes *mongo.BulkWriteResult
}
func BulkWriteSync ¶
func BulkWriteSync(c *Client, collName string, writeModels []mongo.WriteModel, opts ...options.Lister[options.BulkWriteOptions]) BulkWriteResult
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
NewClient return a pointer to gomongo.Client that is used to communicate the Mongodb
Parameters:
host: a host name in the form of mongodb://host:port. Fool explanation can be found at [https://www.mongodb.com/docs/drivers/go/current/fundamentals/connections/connection-guide/] database: The client is aim to work with a single database. so you can set its name at the initialization stage. connTimeout: The timeout of the operations against the database. If you do not set it will set to the default of 10 seconds
func (*Client) UseTransaction ¶
func (c *Client) UseTransaction(transactionFunc TransactionFunc) error
type CommandResult ¶
type CommandResult struct {
DbRes *mongo.SingleResult
Err error
}
func RunCommandSync ¶
func RunCommandSync(c *Client, cmd any, opts ...options.Lister[options.RunCmdOptions]) CommandResult
RunCommand run a command on the database
type CountResult ¶
func CountDocumentsSync ¶
func CountDocumentsSync(c *Client, collName string, filter any, opts ...options.Lister[options.CountOptions]) CountResult
CountDocuments count the documents that return from the filter
type DeleteResult ¶
func DeleteManySync ¶
func DeleteManySync(c *Client, collName string, filter any, opts ...options.Lister[options.DeleteManyOptions]) DeleteResult
DeleteManySync delete many documents from a collection. work in a sync way for options and details mongo deleteon command see: [https://www.mongodb.com/docs/drivers/go/current/usage-examples/deleteOne/]
func DeleteOneSync ¶
func DeleteOneSync(c *Client, collName string, filter any, opts ...options.Lister[options.DeleteOneOptions]) DeleteResult
DeleteOneSync delete on document base on the filter string for options and details mongo deleteon command see: [https://www.mongodb.com/docs/drivers/go/current/usage-examples/deleteOne/]
type DistinctResult ¶
func DistinctSync ¶
func DistinctSync[T any](c *Client, collName string, fieldName string, filter any, opts ...options.Lister[options.DistinctOptions]) DistinctResult[T]
type IndexCreateResult ¶
func CreateIndexSync ¶
func CreateIndexSync(c *Client, collName string, indexDef any, idxOpt *options.IndexOptionsBuilder) IndexCreateResult
type IndexDropResult ¶
func DropAllIndexSync ¶
func DropAllIndexSync(c *Client, collName string, opts ...options.Lister[options.DropIndexesOptions]) IndexDropResult
func DropIndexSync ¶
func DropIndexSync(c *Client, collName string, name string, opts ...options.Lister[options.DropIndexesOptions]) IndexDropResult
type IndexListResult ¶
func ListIndexSync ¶
func ListIndexSync(c *Client, collName string, opts ...options.Lister[options.ListIndexesOptions]) IndexListResult
type ReadManyResult ¶
func AggregateSync ¶
type ReadOneResult ¶
type ReadOneResult[T any] struct { Found bool Document T Err error DbRes *mongo.SingleResult }
func FindOneSync ¶
func FindOneSync[T any](c *Client, collName string, filter any, opts ...options.Lister[options.FindOneOptions]) ReadOneResult[T]
FindOneSync sync version of searching for a single document in a collection
type ReadStreamResult ¶
type ReadStreamResult[T any] struct { DocumentStream chan ReadOneResult[T] Err error }
func FindStreamSync ¶
func FindStreamSync[T any](c *Client, collName string, filter any, opts ...options.Lister[options.FindOptions]) ReadStreamResult[T]
type TransactionFunc ¶
type TransactionFunc func(client *Client) (TransactionResult, error)
TransactionFunc is called in a transaction session If all is well the function should return true and error should be nill other wise return false. if you want to pass an error to the calling
type TransactionResult ¶
type TransactionResult string
const ( TransactionResultCommit TransactionResult = "commit" TransactionResultAbort TransactionResult = "abort" )
type UpdateResult ¶
type UpdateResult struct {
DbRes *mongo.UpdateResult
Err error
}
func ReplaceOneSync ¶
func ReplaceOneSync(c *Client, collName string, filter any, document any, opts ...options.Lister[options.ReplaceOptions]) UpdateResult
func UpdateManySync ¶
func UpdateManySync(c *Client, collName string, filter any, instruction any, opts ...options.Lister[options.UpdateManyOptions]) UpdateResult
func UpdateOneSync ¶
func UpdateOneSync(c *Client, collName string, filter any, instruction any, opts ...options.Lister[options.UpdateOneOptions]) UpdateResult
type WriteManyResult ¶
type WriteManyResult struct {
DbRes *mongo.InsertManyResult
Err error
}
func InsertManySync ¶
func InsertManySync[T any](c *Client, collName string, documents []T, opts ...options.Lister[options.InsertManyOptions]) WriteManyResult
**************************************************************************************************************** **************************************************************************************************************** ****************************************************************************************************************
SYNC methods
**************************************************************************************************************** **************************************************************************************************************** ******************************************************************************************************************
type WriteOneResult ¶
type WriteOneResult struct {
DbRes *mongo.InsertOneResult
Err error
}
func InsertOneSync ¶
func InsertOneSync(c *Client, collName string, document any, opts ...options.Lister[options.InsertOneOptions]) WriteOneResult
InsertOneSync insert one document to collection.