1

我有一个如下所示的服务器响应:

[{
  id: 1,
  title: 'Some Article',
  related_articles: {
    total: 4,
    results: [
      { id: 2, title: 'Some other article' },
      { id: 3, title: 'Yet another article' },
    ]
  }
}]

正如你所看到的,让这件事变得棘手的是它并不简单arrayOf:我想规范化article.related_articles.results.

我试过这个,无济于事:

articleSchema.define({
  related_articles: {
    results: arrayOf(relatedArticleSchema),
  },
});

似乎支持的关系必须是“顶级”。

任何人都知道我怎么能得到类似的东西:

[{
  id: 1,
  title: 'Some Article',
  related_articles: {
    total: 4,
    results: [2, 3]
  }
}]

谢谢!

4

1 回答 1

1

您的方案定义了一个键“relatedArticles”,但它应该是snake_case,“related_articles”

于 2017-01-27T22:14:30.150 回答