社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  MongoDB

如何过滤mongodb中的两个数组?

Adnan Babai • 4 年前 • 296 次点击  

我有两种类型的学期第一种是可信的,另一种是全部。这两种类型都有插入多个课程的课程数组。我想做一个逻辑,当服务器接收到记录获取请求时。在这里,它检查学期类型是否可信,然后在将数据发送到客户端之前执行一些条件。

条件是。

检查完学期类型后。 普莱松 数组输入 用户架构 . 当用户下次登录时,服务器将匹配 第一学期的要素和课程以及下两节课的发送通过的课程。

这是记录获取请求

server.get('/load-record', (req, res, next) => {
    Record.find({})
        .populate({
            path: 'semesters', populate: {
                path: 'lessons',
                options: {
                    // limit: 2
                }
            }
        })
        .populate({ path: 'events' })
        .exec((err, data) => {
            if (err) throw err;
            console.log(data[0].semesters)
            res.send({ status: true, loadedData: data })
        })
})

 const userSchema = mongoose.Schema({
   username: { type: String, required: true },
   city: { type: String, required: true },
   password: { type: String, required: true },
   status: { type: String, required: true },
   imagePath: { type: String },
   date: { type: Date, default: Date.now },
   lastLoggedAt: { type: Date },
   Jlesson: [{
    type: mongoose.SchemaTypes.ObjectId,
    ref: 'JLesson'
    }],
   Plesson: [{ type: Object }] 
    })
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/53778
 
296 次点击