可以在四张桌子上填充深度填充的工作

时间:2019-05-15 01:25:34

标签: mongoose mongoose-populate

mongoose-deep-populate模块可以在两个以上的集合中进行填充。

以下来自文档:

library(tidyverse)

models = list(y ~ I(x^0.5), y ~ I(log(x)))

tibble(x=1:100) %>% 
  mutate(y=log(x) + rnorm(n(), 0, 0.1)) %>% 
  ggplot(aes(x=x, y=y)) + 
    geom_point() + 
    map(models, ~ geom_smooth(method='lm', formula=.))

我的问题是,您能否填充喜欢评论的用户,例如:

var UserSchema = new Schema({})

var CommentSchema = new Schema({
  user  : {type: Number, ref: 'User'}
})

var PostSchema = new Schema({
  user    : {type: Number, ref: 'User'},
  comments: [{type: Number, ref: 'Comment'}],
  likes   : [{user: {type: Number, ref: 'User'}}],
  approved: {status: Boolean, user: {type: Number, ref: 'User'}}
})

post.deepPopulate('user comments.user likes.user approved.user', cb);

0 个答案:

没有答案