Skip to content

Instantly share code, notes, and snippets.

@danmichaelo
Created January 4, 2024 12:01
Show Gist options
  • Save danmichaelo/50e8f4405d4d517ad89302b2fb7d3b6c to your computer and use it in GitHub Desktop.
Save danmichaelo/50e8f4405d4d517ad89302b2fb7d3b6c to your computer and use it in GitHub Desktop.
[
{
$match: {
data: {
$exists: true,
},
},
},
{
$unwind: {
path: "$data.genres",
},
},
{
$match: {
"data.genres.isForm": true,
},
},
{
$group: {
_id: "$data.id",
title: {
$first: "$data.title.mainTitle",
},
forms: {
$addToSet: "$data.genres.name.nb",
},
},
},
{
$match: {
"forms.1": {
$exists: true,
},
},
},
{
$addFields: {
forms: {
$sortArray: {
input: "$forms",
sortBy: 1,
},
},
},
},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment