如何在MoleculerJS中使用不同字段而不是_id解析populate

huangapple go评论93阅读模式
英文:

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

问题

我正在创建一个用于从MongoDB查询Tasks集合的服务。它具有一个名为uId的自定义id字段,以及一个任务模型中的名为subtask的字段,该字段存储其他任务的uId。我希望填充subtask字段,任务模型如下 task model

我期望用uId填充subtask字段。

英文:

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

答案1

得分: 0

在你的服务中使用idField

{
  settings: {
    idField: "uId"
  }
}

文档参考链接

英文:

Use idField in your service:

{
  settings: {
    idField: "uId"
  }
}

Documentation reference

huangapple
  • 本文由 发表于 2023年2月8日 15:03:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75382351.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定