sails.js 使用水线并且有一个很好的文档。
User.findOne()
.where({ id: 2 })
.then(function(user){
var comments = Comment.find({userId: user.id}).then(function(comments){
return comments;
如果我忽略"id: 2"
并只使用 find() 而不是findOne()
查询仍然有效,但为什么呢?find()
应该返回一个列表,所以我不能只在子查询中说 user.id
Comment.find({userId: user.id})
如果我没有收到一条记录而是一个用户列表,我该如何访问?