Apply for Zend Framework Certification Training

MongoDb





async getAllTaskTimeLog(userId): Promise {
    try {
      this.logger.info(LoggerMessages.FIND_ALL_TASK_TIMELOG_STARTED)
      var rules = [{ 'userId': userId }];
      const date = DateCalc.todayCalc();
      var rules2 = [{
        'userId': userId,
        trackingStartTimestamp: { "$gte": date.start },
        trackingEndTimestamp: { "$lt": date.end }
      }];
      let activtiyList: any = await this.userActivityModel.aggregate([
        { $match: { $and: rules } }, {
          $group: {
            _id: { taskId: '$taskId', userId: '$userId', projectId: '$projectId' },
            totalTime: { $sum: "$trackingInterval" },
            userTime: { $sum: "$trackingInterval" },
          }
        }]);
      let todayActivtiyList: any = await this.userActivityModel.aggregate([
        { $match: { $and: rules2 } }, {
          $group: {
            _id: { taskId: '$taskId', userId: '$userId', projectId: '$projectId' },
            totalTime: { $sum: "$trackingInterval" },
            userTime: { $sum: "$trackingInterval" },
          }
        }]);
      activtiyList = this.getUserTimeLog(activtiyList, todayActivtiyList);
      this.logger.info(LoggerMessages.FIND_ALL_TASK_TIMELOG_ENDS)
      return activtiyList;
    } catch (err) {
      this.logger.info(LoggerMessages.FAILED_TO_FIND_ALL_TASK_TIMELOG, err)
      throw new EnsoCommonException(EnsoAppErrorMessage.FAILED_TO_FIND_ALL_TASK_TIMELOG, EnsoAppErrorCode.ENSO_APP_ERROR_CODE, err);
    }


  }

< Uses of where condition in mongoDb Uses of Projection in mongoDb with nodeJs >



Ask a question



  • Question:
    {{questionlistdata.blog_question_description}}
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question


Back to Top