Skip to content

Latest commit

 

History

History
35 lines (35 loc) · 548 Bytes

mongodb.md

File metadata and controls

35 lines (35 loc) · 548 Bytes

GROUPBY 操作

mongodb 聚合:

{
    _id: "$type",
    items: {
        $push: {
            name: "$name",
            url: "$url",
            coverage: "$coverage",
            singer: "$singer"
        }
    },
    count: {
        $sum: 1
    }
}

unicloud中使用方法:

db.collection('music').aggregate().group({
		_id: "$type",
		items: {
			$push: {
				name: "$name",
				url: "$url",
				coverage: "$coverage",
				singer: "$singer"
			}
		},
		count: {
			$sum: 1
		}
	}).end()