These are chat archives for Automattic/mongoose

Oct 2018
Oct 30 2018 10:09
@mbellemo_twitter The $and in your filter is superfluous because it only has one condition gist here.
Another approach would be to create a text index on the fields associated with your and use text search to look for the values in both fields with one $text property on your filter gist here. There are plenty of caveats with text indexes though. So be sure to check out the docs before changing anything.
Slim Hmidi
Oct 30 2018 15:29
Hi, is it possible to combine aggregate with populate in mongoose??

I wrote this query:

const filteredTasks = await Tasks.aggregate([])
        .match({ statusId: native.Types.ObjectId(statusId) })
          name: 1,
          typeId: 1,
          statusId: 1,
          position: { $arrayElemAt: [{ $map: {
            input: {
              $filter: {
                input: '$attributes',
                as: 'attribute',
                cond: { $eq: ['$$attribute.attributeId', native.Types.ObjectId('5bd858e29ae710297c649688')] },
            as: 'attributeType',
            in: '$$attributeType.value',

          } }, 0] },

The collection Tasks has join with two other collections through typeId and statusId and I want to populate the query with the referenced collections.How can I do that?