Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zhymin77 opened this issue Aug 6, 2013 · 5 comments
Open

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

zhymin77 opened this issue Aug 6, 2013 · 5 comments

Comments

@zhymin77
Copy link

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 .

tks.

@pomack
Copy link
Owner

pomack commented Aug 6, 2013

I believe mgo uses the bson tag as such:

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

@zhymin77
Copy link
Author

zhymin77 commented Aug 7, 2013

yes, :)

How to define struct like this use thrift4go?

@pomack
Copy link
Owner

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
Copy link
Author

zhymin77 commented Aug 7, 2013

tks 👍

@zhymin77
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants