猫鼬加剧
我看到了很多类似的问题和答案,但是我有点困惑。
如何通过猫鼬的汇总来实现这一目标?
const userId = "23523891729417419";
const students = await Students.find({ active: true });
const courses = await Courses.find({ userId: userId });
const result = students.filter((s) => {
const found = courses.find((c) => c.someId === s.someOtherId);
if (!found) return s;
});
在两个模型中,有一个字段(具有不同的名称),在某些文档上,它们的值可能相等。我想将它们排除在结果之外。
学生和课程只是虚拟的名字。并可能会弄乱这个问题。
I have seen so many similar questions and answers, but and I'm a bit confused.
How can I achieve this with aggregate in mongoose?
const userId = "23523891729417419";
const students = await Students.find({ active: true });
const courses = await Courses.find({ userId: userId });
const result = students.filter((s) => {
const found = courses.find((c) => c.someId === s.someOtherId);
if (!found) return s;
});
There is one field (with differnet names) in both models that on some documents the value of them might be equal. I want to exclude them from result.
students and courses are just dummy names. and might mess with the question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论