MongoDB PHP使用条件聚合数据

时间:2018-09-06 06:44:13

标签: php mongodb aggregation

我有2条不同的管道:有条件的

$pipeline = array(
            array('$match' => array(
                'currentStep' => 'CREATE')),
            array('$group' => array(
                '_id' => '$name',
                'value' => array('$sum' => 1)
            )));

没有

$pipeline = array(
            array('$group' => array(
                '_id' => '$name',
                'value' => array('$sum' => 1)
            )));

如何将它们组合在一个$ pipeline中以获得这样的输出:

_id - value_with_match_condition - value_without

1 个答案:

答案 0 :(得分:0)

为此,您需要结合使用 const file = require("@/assets/audio/mysong.mp3"); it("should test lifecycle when vue instance is destroyed", () => { const wrapper = shallowMount(AudioPlayer, { propsData: { autoPlay: false, file: file, ended, canPlay } }); wrapper.vm.loaded = true; // enable buttons expect(wrapper.contains('#playPauseBtn')).toBe(true); // when wrapper.destroy(); // then expect(wrapper.contains('#playPauseBtn')).toBe(false); }); ● AudioPlayer.vue › should test lifecycle when vue instance is destroyed expect(received).toBe(expected) // Object.is equality Expected: false Received: true $sum。例如,它可能看起来像这样:

$cond

这是未经测试的,但符合此常规形式的内容应该可以工作。