Hi, I'm trying to reference a document by it's ID. This is the struct I have set up:
type Placement struct {
Id bson.ObjectId "_id.omitempty"
Title string "Title.omitempty"
Body string "Body.omitempty"
URL string "URL.omitempty"
Thumbnail string "Thumbnail.omitempty"
Paused bool "Paused"
Spread int "Spread.omitempty"
}
And when inserting data into MongoDB, this is the format I'm using:
newPlacement := Placement{
bson.NewObjectId(),
ctx.Params["Title"],
ctx.Params["Body"],
ctx.Params["URL"],
ctx.Params["Thumbnail"],
false,
spread,
}
That all seems to be working well, but I can't for the life of me load up a document by it's 'Id'. This is the code I'm trying to use:
err := c.Find(bson.M{"Id" : bson.ObjectIdHex(id)}).One(&placement)
When that fires, I'm getting the error: Handler crashed with error not found
I tried changing the code to:
err := c.Find(bson.M{"Id" : bson.ObjectIdHex(id)}).All(&placement)
I'm pretty lost at this point, and am open to any suggestions.
Thank you!