0
0

Mongo リストの合計数、条件付き範囲のクエリー

Posted at
user.js

$project: {
            _id: 1,
            
            totalQuestClearCount: {
                $reduce: {
                    input: { $ifNull: ["$quests", []] },
                    initialValue: 0,
                    in: {
                        $cond: [{ $eq: ["$$this.storyId", 0], $eq: ["$$this.totalClearCount", 1] },
                        { $add: ["$$value", 1] },
                            "$$value"
                        ]
                    }
                }
            },
        }

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0