Documentation ¶
Index ¶
- Constants
- func Count(dbname, collname string, spec bson.M) int
- func ErrorRecord(msg, etype string, ecode int) map[string]any
- func Get(dbname, collname string, spec bson.M, idx, limit int) []map[string]any
- func GetInt64Value(rec map[string]any, key string) (int64, error)
- func GetIntValue(rec map[string]any, key string) (int, error)
- func GetSingleStringValue(rec map[string]any, key string) (string, error)
- func GetSorted(dbname, collname string, spec bson.M, skeys []string) []map[string]any
- func GetStringValue(rec map[string]any, key string) (string, error)
- func GetValue(rec map[string]any, key string) interface{}
- func InitMongoDB(uri string)
- func Insert(dbname, collname string, records []map[string]any)
- func InsertAny(dbname, collname string, records []any)
- func InsertRecord(dbname, collname string, rec bson.M) error
- func MapKeys(rec map[string]any) []string
- func Remove(dbname, collname string, spec bson.M) error
- func Update(dbname, collname string, spec, newdata bson.M)
- func Upsert(dbname, collname, attr string, records []map[string]any) error
- func UpsertAny(dbname, collname string, records []any) error
- func UpsertRecord(dbname, collname string, spec bson.M, rec bson.M) error
- type Connection
Constants ¶
View Source
const ( ServerError DBError QueryError ParserError ValidationError )
View Source
const ( ServerErrorName = "Server error" DBErrorName = "MongoDB error" QueryErrorName = "Server query error" ParserErrorName = "Server parser error" ValidationErrorName = "Server validation error" )
ServerErrorName and others provides human based definition of the error
Variables ¶
This section is empty.
Functions ¶
func ErrorRecord ¶
ErrorRecord provides error record
func GetInt64Value ¶
GetInt64Value function to get int value from record for given key
func GetIntValue ¶
GetIntValue function to get int value from record for given key
func GetSingleStringValue ¶
GetSingleStringValue function to get string value from record for given key
func GetStringValue ¶
GetStringValue function to get string value from record for given key
func InsertRecord ¶ added in v0.3.2
InsertRecord insert record with given spec to MongoDB
Types ¶
type Connection ¶
Connection defines connection to MongoDB
var Mongo Connection
Mongo holds MongoDB connection
func (*Connection) Connect ¶
func (m *Connection) Connect() *mongo.Client
Connect provides connection to MongoDB
Click to show internal directories.
Click to hide internal directories.