//UpsertPhoneInterface
func
UpsertPhoneInterface(_query, update bson.M) (err
error) {
query :=
func(c *mgo.Collection)
error {
_,
err = c.
Upsert(_query, update)
return err
}
getCollection(
"perfInterface", query)
return
}
q := bson.M{
"serial": serial}
p := bson.M{
"serial": serial,
"timestamp": stamptime,
"ip": ip,
"jtype":
"serial-ip"}
log.
Info(q, p)
err = db.
UpsertPhoneInterface(q, p)
if err !=
nil {
ret :=
map[
string]
interface{}{
"code":
"000404",
"msg":
"fail to insert to mongodb"}
return c.
JSON(
400, ret)
}