问题描述
我有一个产品,我有一个属性,它带有一个带有提供者 ID 及其价格的数组。这个想法是每个产品都有一个由多个供应商组成的数组,每个供应商都有自己的价格。
但是,当我使用 populate() 查找 ProviderID 时,它使我填充为字符串而不是 JSON。下面是从带来产品的查询返回的 GraphQL 查询。
![GRAPHQL return](https://i.stack.imgur.com/HAhMZ.png)
ProviderPrice 类,在 ProductModel 内部
![enter image description here](https://i.stack.imgur.com/jTZsd.png)
ProductModel 中的可选参数
![enter image description here](https://i.stack.imgur.com/P8mXm.png)
这就是我执行填充的方式
![enter image description here](https://i.stack.imgur.com/0e3kX.png)
有人经历过吗?
解决方法
发现问题。
我使用了类 ProviderPrice 而不是模型 ProviderPriceModel。