The project i m working on uses mongodb as DB and has a mock data generator. when data is generated via mock data generator it creates objects with string ids into db. And our backend application Spring boot with spring data mongodb stores new objects with _id being ObjectId
{
"_id" : ObjectId("6163686f6c64722d30303031"),
"email" : "Price36@hotmail.com",
"modeOfContact" : "EMAIL",
"name" : "Leonardo Walter",
"phone" : "08802273531"
}
{
"_id" : "customer-1",
"email" : "Casimer_Jakubowski@hotmail.com",
"modeOfContact" : "EMAIL",
"name" : "Kennedy Kilback",
"phone" : "07624333004"
}
now we have a node based application for fetch calls only that uses "mongodb" package to resolve queries.
when i do following query for objects with String _id it works
findDocument(COLLECTION_NAME, { _id: args.id})
but the query fails when objects have _id as ObjectId
is there a way where i can search for objects by providing _id and data type as well
like
findDocument(COLLECTION_NAME, { _id: args.id , $type: [ 'string', 'ObjectId']})
i know with $type it will return all records with _id's matching that type. just trying to explain what i wanna achieve here.