Closed aurickislam closed 3 years ago
Hello @aurickislam ,
Take a look at this issue - https://github.com/oatpp/oatpp-mongo/issues/6
You'll need that objectIdFromString
method:
auto result =
collection.find_one(createMongoDocument( // <-- Filter
oatpp::Fields({
{"_id", objectIdFromString("5f3258cfbaaccedaa5dd2d96")}
})
));
This is for now. Later, ObjectId will have a from-string constructor.
Thanks it worked. But needed to specify oatpp::Fields
type to oatpp::Fields<oatpp::Any>
auto result =
collection.find_one(createMongoDocument( // <-- Filter
oatpp::Fields<oatpp::Any>({
{"_id", objectIdFromString("5f3258cfbaaccedaa5dd2d96")}
})
));
Thanks it worked. But needed to specify oatpp::Fields type to oatpp::Fields
Yes, you are correct. Thanks for posting the correct answer!
How can I query by "_id" : ObjectId?. For example: