Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 {
|
func (that *mongoDb) Get(table string, where Map) Map {
|
||||||
results := []Map{}
|
results := []Map{}
|
||||||
var cursor *mongo.Cursor
|
var cursor *mongo.Cursor
|
||||||
|
|||||||
Reference in New Issue
Block a user