NodeJS MongoDB populate() 带来字符串而不是 JSON

问题描述

我有一个产品,我有一个属性,它带有一个带有提供者 ID 及其价格的数组。这个想法是每个产品都有一个由多个供应商组成的数组,每个供应商都有自己的价格。

但是,当我使用 populate() 查找 ProviderID 时,它使我填充为字符串而不是 JSON。下面是从带来产品的查询返回的 GraphQL 查询。

GRAPHQL return

ProviderPrice 类,在 ProductModel 内部

enter image description here

ProductModel 中的可选参数

enter image description here

这就是我执行填充的方式

enter image description here

有人经历过吗?

解决方法

发现问题。

我使用了类 ProviderPrice 而不是模型 ProviderPriceModel。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...