I'm really sorry about this topic. I see many others, but anything could help me to solve my problem.
So, I'm using Go + mgo in my backend and the structure that I have to search for is:
type Video struct {
ID bson.ObjectId `bson:"_id,omitempty"`
Title string `bson:"title"`
Duration string `bson:"duration"`
Url string `bson:"url"`
DefaultThumb string `bson:"defaultthumb"`
SiteID SiteProfile `bson:"siteid"`
}
The table "videos" has 2kk+ of information and first, I have to select these videos from his site profile that has stored in this structure:
type SiteProfile struct {
ID bson.ObjectId `bson:"_id,omitempty"`
Name string `bson:"name"`
Site string `bson:"site"`
ExportUrl string `bson:"exportUrl"`
ExportType string `bson:"exportType"`
}
Then, I'm doing this command to fetch the requests that have same profile, inside a loop of profiles:
var videos []Video
collVideos.Find(bson.M{"siteid.name": profile.Name}).All(&videos)
In the log messages, I'm getting an empty array and doing the same thing using Robomongo, that is node based, I have these rows listed by they site profile normally. So, does anybody know how can I retrieve these data, searching for the nested object?
Thank you for your help!
Well, it is really weird, but when I rewrite the code, verifying the error from the find method, it works. I just did this:
var videos []Video
err := collVideos.Find(bson.M{"siteid.name": profile.Name}).All(&videos)
CheckError(err)