forked from golang/hotime
增加mongodb驱动,简单版本
This commit is contained in:
parent
30edb4d9fa
commit
f31bf24ec2
@ -65,6 +65,32 @@ func (that *mongoDb) InsertMany(table string, data ...interface{}) Slice {
|
||||
|
||||
}
|
||||
|
||||
func (that *mongoDb) Update(table string, data Map, where Map) int64 {
|
||||
collection := that.DataBase.Collection(table)
|
||||
re, err := collection.UpdateMany(that.Ctx, where, data)
|
||||
|
||||
if err != nil {
|
||||
that.LastErr = err
|
||||
return 0
|
||||
}
|
||||
|
||||
return re.ModifiedCount
|
||||
|
||||
}
|
||||
|
||||
func (that *mongoDb) Delete(table string, where Map) int64 {
|
||||
collection := that.DataBase.Collection(table)
|
||||
re, err := collection.DeleteMany(that.Ctx, where)
|
||||
|
||||
if err != nil {
|
||||
that.LastErr = err
|
||||
return 0
|
||||
}
|
||||
|
||||
return re.DeletedCount
|
||||
|
||||
}
|
||||
|
||||
func (that *mongoDb) Get(table string, where Map) Map {
|
||||
results := []Map{}
|
||||
var cursor *mongo.Cursor
|
||||
|
Loading…
Reference in New Issue
Block a user