Search code examples
moleculer

How to resolve populate with different field instead of _id in MoleculerJS


I am creating a service to query Tasks collection from the MongoDB. It have a custom id field called uId, and a task store other uId of other taks in its field named subtask. I want to populate the field subtask, the task model is this task model

I expect to populate the field subtask with uId


Solution

  • Use idField in your service:

    {
      settings: {
        idField: "uId"
      }
    }
    

    Documentation reference