Four Stars

MongoDB string to object Id



I want 2 things:

1. I am doing a lookup with a master and want to bring the reference value and its objectId. The objectId is converted to string. Is there any way to convert string to object id type?


2. Any way to generate an object ID for nested objects?


Thanks in advance.