This is a creation in Article, where the information may have evolved or changed.
The syntax for finding and displaying specific key-value pairs in a MongoDB shell is:
> Db.logs.Find({},{"Log":1}){ "_id":"3a06384a40a8e587806f194c6c80253e","Log":"This is a test log" }{ "_id":"36BB718040A4362B8035EBD822125DBA","Log":"This is a test log"}
The above instruction is to find all documents and display key value pairs "log".
If you need to not display "_id" key value pairs, you can write this
> Db.logs.Find({},{"_id":0,"Log":1}){ "Log":"This is a test log" }{ "Log":"This is a test log"}
The MgO notation in Golang needs to be implemented with the Select () method in MgO, with the following code:
Err = D.find (Bson. m{}). Select (Bson. m{"log"1}). All (&RESULT1)
The syntax for updating inline document key-value pairs in MongoDB is as follows:
Err = collection. Update (Bson. m{"_id": 123456}, Bson. m{"$set": Bson. m{"Info.name": "New"}})
The above instruction function is to update the "name" key value pair under "info" in the 123456 document "_id".