我创建了这个架构,我想计算去年的平均登录时间
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var logSchema= new Schema({
email: {type:String,required:true},
loginTime: {type:String,required:true},
loginDate: {type:Date,required:true}
});
var log= mongoose.model('Log',logSchema);
module.exports = log;
我使用此代码,但它不起作用。我可以使用什么
var Log= require('../models/log');
function calculateLogTime(time){
var current_date = new Date();
var formattedDate = simpleDate.format(current_date, 'dashed');
Log.average({loginDate:formattedDate},{$avg:'$loginTime'},function(err,count){
console.log( "Avarage", count );
time(count);
});
}