C++ GetField() function

316 views
Skip to first unread message

yagru_alvarez

unread,
Dec 9, 2010, 9:39:40 AM12/9/10
to mongodb-user
I want to obtain the value of the age that I insert into mongo, the
function GetField() doesn't have match for integer??, I have that
error when I try this:

BSONObj p = cursors->next();
int value = p.getField("age");

error: cannot convert ‘mongo::BSONElement’ to ‘int’ in initialization

Eliot Horowitz

unread,
Dec 9, 2010, 9:41:21 AM12/9/10
to mongod...@googlegroups.com
try

p["age"].Int()

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages