如何在猫鼬中按时间戳分组?

时间:2020-05-25 14:58:11

标签: javascript node.js mongodb mongoose mongoose-schema

我有一个这样的架构:

const UsageSchema = mongoose.Schema({
    waterUsed:{
        type: Number,
        required : true
    },
    flow:{
        type:Number,
        required: true
    },
    tank: {
        type: String,
        required: true,
        ref: 'Tank'
    }

}, {
    timestamps: true
});

我想从时间戳记中获得HOUR(使用的总TOTAL)最高。 也就是说,在过去的24小时内,我需要找到一个小时,在该小时内,在该小时内添加的所有用法的waterUsed之和最高。

有关如何实现此目标的任何指示?

0 个答案:

没有答案