Add Upsert 方法
This commit is contained in:
parent
f5fd0f9309
commit
0391e1a006
18
dbpool.go
18
dbpool.go
@ -143,10 +143,22 @@ func (this *dbPool) Replace(
|
||||
func (this *dbPool) Upsert(
|
||||
dataSource string,
|
||||
tblName string,
|
||||
whereKv map[string]string,
|
||||
updateKv map[string]string,
|
||||
insertKv map[string]string,
|
||||
whereKv [][]string,
|
||||
updateKv [][]string,
|
||||
insertKv [][]string,
|
||||
cb ExecResultCb) {
|
||||
this.OrmSelectOne(dataSource, tblName, whereKv,
|
||||
func(err error, ds *DataSet) {
|
||||
if err != nil {
|
||||
cb(err, 0, 0)
|
||||
return
|
||||
}
|
||||
if ds.Next() {
|
||||
this.Update(dataSource, tblName, updateKv, whereKv, cb)
|
||||
} else {
|
||||
this.Insert(dataSource, tblName, insertKv, cb)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (this *dbPool) PageQuery(
|
||||
|
Loading…
x
Reference in New Issue
Block a user