In a language learning app, each time a user learns a new sentence(which is a document in itself), I would like to add that as a child of the user, so that for each user you can see the sentences that they have already learned.
This is all fine to do with
sentences: [{
type: mongoose.Schema.ObjectId,
ref: 'Sentence'
}]
However, I would like to add data about that user's relationship with the child, e.g. firstLearnedOnDate: , totalCorrectAnswers: etc. Is this possible in mongoose? Is there a better solution that I'm missing?
I have tried messing around with putting the mongoose.Schema.ObjectId into another object with the other properties which I want, but that didn't work.
question from:
https://stackoverflow.com/questions/65848310/unique-parent-child-relationship-data-in-mongoose 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…