aggregation

How do I only return SOME fields ($project) from Mongodb aggregation, while also using $match, $lookup AND $filter

匆匆过客 提交于 2020-06-27 05:50:25
问题 I am VERY close to getting what I want out of this query... but I only want SOME of the fields returned and right now it is returning all of them NOTE : This is a refinement : I am now asking how to return only certain fields , while my similar question asks how to return the data between a start and end date In addition, can somebody please please provide an answer using the MongoDB Playground with MY data sets so I can try it out... I can't quite figure out how to "name" the data sets so

How do I FILTER returned data between two dates from mongodb using an aggregation : match, lookup and project?

只愿长相守 提交于 2020-06-08 15:57:07
问题 I would like to get all Notifications between a start and end date that are related to a Register when I pass in a userId. Register Schema const mongoose = require('mongoose'); const Schema = mongoose.Schema; const RegisterSchema = new Schema({ userId: {type: Schema.Types.ObjectId, required: true}, accessToken: {type:String, required: true, default: null}, }) module.exports = Register = mongoose.model( 'register', RegisterSchema) Here is some register data [ { "_id": "5eac9e815fc57b07f5d0d29f