DB-ref in mongoose without Schema.ObjectId?
mongodb, mongoose, node.js
Solution
No, only `ObjectId` values that refer to the `_id` property of another collection can be used as refs.
Confirmed in the source code.
Problem
in my code people can follow other people. So far everything is ok apart from this fact: in the userScheme I have this field. ``` , following: [{ type: Schema.ObjectId, ref: 'Users' }] ``` Since every user has an username, it's more versatile for me to use dbref with the username. is there a way to do something like this? ``` , following: [{ type: Users.username, ref: 'Users' }] ``` Many thanks, g