Home  >  Q&A  >  body text

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

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

漂亮男人漂亮男人2709 days ago693

reply all(1)I'll reply

  • PHP中文网

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

    I have solved it myself

    See [httpmongo]https://github.com/golangframework/httpmongo/blob/master/collection.go for details

    Mongodb provides a method of complete replacement based on _id
    I used the method of remove first, then insert to implement the save operation, which also ensures that data that meets the filter conditions will not be repeated multiple times.

    reply
    0
  • Cancelreply