在此代码中,我试图根据.但是每当我运行此代码时,它都会给我一个错误.userID
mongo: no documents in result
我也用mongo shell写,但它给了我一个结果。尽管数据存在于MongoDB数据库中。这是要看的图片。db.dataStored.findOne({_id: ObjectId("60a60718503219dfd740f9fe")})
null
userID := "60a60718503219dfd740f9fe"
var result Trainer
collection := client.Database("PMS").Collection("dataStored")
err = collection.FindOne(context.TODO(), bson.M{"_id": userID}).Decode(&result)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Found a single document: %+v\n", result)
呼如林
相关分类