Heim  >  Fragen und Antworten  >  Hauptteil

golang - mgo (mongodb go)如何进行类似shell 的save 或者c#驱动的replace操作?

mgo (mongodb go)如何进行类似shell 的save 或者c#驱动的replace操作?

漂亮男人漂亮男人2709 Tage vor696

Antworte allen(1)Ich werde antworten

  • PHP中文网

    PHP中文网2017-04-28 09:08:20

    本人已经自己解决了

    详见[httpmongo]https://github.com/golangframework/httpmongo/blob/master/collection.go

    mongodb提供了一个根据_id进行完全替换的方法
    我采用了先remove,再insert的方法,实现了save操作,这样也保证了符合filter条件的数据不会重复多条。

    Antwort
    0
  • StornierenAntwort