Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

how to use thrift query mongo '_id' field? #64

zhymin77 opened this Issue Aug 6, 2013 · 5 comments


None yet
2 participants

zhymin77 commented Aug 6, 2013

how to struct a field, when i extract mongo '_id' field's value?
I use mgo driver.
I can define a Struct like that:
type Test struct {
ID string "_id"
extract '_id' value to ID field successfully .



pomack commented Aug 6, 2013

I believe mgo uses the bson tag as such:

type Test struct {
  ID string `bson:"_id"`

zhymin77 commented Aug 7, 2013

yes, :)

How to define struct like this use thrift4go?


pomack commented Aug 7, 2013

Thrift doesn't support this in the spec file and therefore there's no way to auto-generate with tags this way. You can create your own structs and then write conversion functions between the auto-generated struct and your own struct.

zhymin77 commented Aug 7, 2013

tks 👍

zhymin77 commented Aug 7, 2013

I use a helper to convert query map data to thrift obj.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment