The purpose of ForeignKey is to prevent the creation of data if the field value does not match its ForeignKey. To accomplish this in MongoDB, we use Schema middlewares that ensure the data consistency.
Please have a look at the documentation.
https://mongoosejs.com/docs/middleware.html#pre