我认为问题很容易理解,但我找不到一个好的解决方案。
在系统中,用户有一些偏好以及此偏好的权重,例如:
$ps.addscript("function write-host($out) {write-output $out}").invoke()
$ps.commands.clear()
因此,如果将为用户生成一个提要,对于每10个请求的新闻,将需要有3个篮球,4个足球和3个高尔夫新闻。因此,在我的新闻集合中,我需要一些支持分页的查询,这将考虑权重,始终以此用户的模式给出结果。
考虑到新闻集合就像这样:
{_id: ,
name: "John",
preferences: [{sku:"Golf", weight: 3},
{sku:"Football", weight: 4},
{sku:"Basketball", weight: 3}]
}
查询必须根据用户权重给我新闻并支持一些分页,现在我正在使用{ _id: ,
text: "A really nice Hole in One after a par"
category: "Golf"
},
{ _id: ,
text: "Real Madrid wins"
category: "Football"
},
...
但是非常丑陋,可能会有非常糟糕的表现,有什么建议吗?