I need to be able to do search on ids based on a regex (I want to preform a "like" operation on the id).
I tried using regex
db.getCollection('aaa').find( {_id:/5a741dcd395b01425ee66770/})
I also try with regex
db.getCollection('aaa').find( {_id:{$regex:"5a741dcd395b01425ee66770"}})
I know the id is a mongo object and that it why it wont work. But I still need this functionality.
I thought maybe create another id that save the id as a string so that I have 2 ids fields, one for search and 1 when the insert occurs, but this complicate staff as when my code do insert I will then need to do update on it from the result id. Is there a way to do it automatically or a better way to achieve this ?