mongodb - 请教Mongoose嵌套数据Schema定义问题?
怪我咯
怪我咯 2017-05-02 09:18:04
0
1
731

请问下这样的数据应该如何定义Schema,怎么用push操作List数组?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
我想大声告诉你

If the outermost List can be changed to an array, it can be defined in the following way

const childChildSchema = new mongoose.Schema({
    PlayerID: Number,
    Msg: String,
    Time: Date
});
const childSchema = new mongoose.Schema({
    PlayerID: Number,
    ReadLast: Date,
    List:[childChildSchema]
});
const parentSchema = new mongoose.Schema({
    ID: Number,
    List: [childSchema]
});
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template