These are chat archives for Automattic/mongoose

31st
Mar 2016
Bnaya Peretz
@Bnaya
Mar 31 2016 08:18
const variantSchema = new Schema({
    differentiator: Schema.Types.Mixed,
    storageEntry: { type: Schema.Types.ObjectId, ref: 'Storage' }
});

const schema = new Schema({
    type: String,
    variants: [variantSchema],
}, {
    timestamps: true
});
I want to populate the variants[].storageEntry, is it possible to do so?
Or it has to be flat array of ids
Bnaya Peretz
@Bnaya
Mar 31 2016 10:19
that was more simple then i expected :) doc.populate<IAsset>('variants.storageEntry'
Petris
@a3bhea
Mar 31 2016 13:13
I want to skip and limit in order for pagination to work but this does not work and gives me all results instead
 query.find({})
                .sort('-created')
                .populate('user', 'name username')
                .populate('tags', 'title color')
                .populate('categories', 'title')
                .skip(itemsPerPage*page)
                .limit(itemsPerPage)
                .exec(function(err, projects) {