These are chat archives for Automattic/mongoose

12th
Jun 2018
Chris Rutherford
@cjrutherford
Jun 12 2018 00:42
so.... I'm not sure, but I'm wanting to have an array of documents referenced in another Schema. Would this be a good approach?
const model = new Schema({
    arrayOfModels: {type: [Schema.Types.ObjectId], ref: 'model'}
});
Paul "Joey" Clark
@joeytwiddle
Jun 12 2018 00:44
If that doesn't work well Chris, you could try:
const model = new Schema({
    arrayOfModels: [{type: Schema.Types.ObjectId, ref: 'model'}]
});
That looks more correct to me. I suppose the way to test is to see if .populate('arrayOfModels') works or not.
Chris Rutherford
@cjrutherford
Jun 12 2018 01:01
okay, sounds good! Thanks!!