These are chat archives for Automattic/mongoose

7th
Nov 2018
Slim Hmidi
@slim-hmidi
Nov 07 2018 10:38

Hi, maybe I tried to do not logical thing but I wrote this query:

Tasks.aggregate([])
        .match({ 'name': 'tasks' })
        .project({
          ids: {
            $map: {
              input: '$links',
              as: 'link',
              in: { id: '$$link.id' },
            },
          },
        });

I got :

/* 1 */
{
    "ids" : [ 
        "5be1c6f0161d2547240e16b9"
    ]
}

/* 2 */
{
    "ids" : [ 
        "5be2b25ee3fcb71fcc82e5ba"
    ]
}

I want to make something like this:

"ids": [ "5be1c6f0161d2547240e16b9",  "5be2b25ee3fcb71fcc82e5ba"]

I tried using group() but I didn't have any id to group the data.Is it possible to combine these data coresponding to different document ids?

Anthony Garo
@agaro1121
Nov 07 2018 15:39
hi everyone
I’m doing a bulkwrite and getting back duplicate key errors
This is expected.
I want to separate which records failed to get written and which were successful
is there an easy way to do this?
it seems the error response stops at the first error