I have a process that is inserting a struct into a table:
type Info struct {
ID bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"`
... other
}
data := &Info{}
data.ID := bson.NewObjectID()
...
// do the insert - all OK
I now need to pass the ObjectId to another process that will extract the record and do other work - here's where I'm running into problems/misunderstanding something fundamental:
cmd := exec.Command("./otherProcess" "-id=", data.ID.Hex())
cmd.Start()
In the otherProcess, I'm doing this:
recordId := bson.ObjectIdHex(*examID) // *examID is read (works) from the commandline arg "-id"
session.DB("myDB").C("MyCollection").FindId(bson.M{"_id": recordId}).One(&result)
No records are found (the ObjectId *is* in the mongo collection). So the issue I'm having is how to properly pass the ObjectId as a String to another process, and properly convert the string to a bson.ObjectId for lookup.
TIA!