These are chat archives for Automattic/mongoose

Oct 2018
Oct 04 2018 04:16
is there a way not to cast to ObjectId when using an aggregate?
subhashish negi
Oct 04 2018 05:47
    productModel.aggregate( [ 
        {$match:{ txtProductName: { $regex:regexStr}} },
            $lookup: {
              from: 'productSeller',
              foreignField: 'productId',
              as: 'productDetails'
        if(err) {
        else {
in resp i am getting results and array 'productDetails'. IN productDetails i have a parameter as id according to that id i have to find name from another collection is it possible by aggregation itself ?
Oct 04 2018 09:25
@campanagerald mongoose doesn't cast values in aggregate ( or at least it shouldn't be )
@subhashish12 it sounds like you need to add another $lookup stage, maybe with an $unwind stage before it on the array path that contains the localField. It's hard to say without seeing a more complete example ( schema, example docs )