These are chat archives for Automattic/mongoose

21st
Nov 2015
iSayme
@isayme
Nov 21 2015 02:52
@diegoaguilar by setting transform options to your schema would fit your need, here is a example:
UserSchema.set('toJSON', {
transform: function(doc, ret, options) {
delete ret.password; // just delete password field when toJSON
}
});
This message was deleted
simonlmartin
@simonlmartin
Nov 21 2015 12:14
Hi, I am having trouble with populate.... my populate code looks like this
    var q = productModel.findOne({
        state: 'published',
        skuBase: locals.filters.skuBase
    }).populate('creator').
        populate('categories').
        populate({
            path:'components.allowedMaterials.materialRef'
            populate : {
                path: 'measures.measureAttributes.measureAttributeKey'
            }
        }).
        lean();
where components.allowedMaterials.materialRef is a sub schema pointing at another model (Material) and measures.measureAttributes.measureAttributeKey is a subschema on Material pointing at another model MeasureAttribute. The Material is found but the MeasureAttribute model is never resolved.