我的用例是在MongoDB中联合两个不同的集合,这两个集合具有大致相同的业务意义,但存储在两个不同的集合中。我在link找到了答案 因此,为了合并两个集合并创建视图,我使用下一个管道 // Here we do a union of the employees and freelancers using a single aggregation query.
db.createView(
"employeesAndFreelancers",
"employees",
[
{ $limit: 1 }, // 2. Keep only on
猫鼬的工作效果很好。但是,有人可以使用填充来通过另一个不是_Id的属性来提取文档吗?
例如,注释模式:
var CommentSchema = new Schema({
_id:Auto Generated
postId:1,
userId:411,
comment:'This is a comment',
// Would want to fetch Like via the userId not likes _id
likes: {
type:mongoose.Schema.Types.ObjectId, // This will have