請問下這樣的資料該如何定義Schema,怎麼用push操作List數組?
走同样的路,发现不同的人生
如果最外層 List 可以改成數組的話,可以用以下方式定義
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] });
如果最外層 List 可以改成數組的話,可以用以下方式定義