0

Hi m working to load data from mongodb but it is loading all data at once i wants to load only that loggedin user related data,

code:

  async function getMeetingsViewData(req) {
try {
  checkRoles(req);

  const meetings = await Meeting.find({
    $or: [{ "attendees.user": req.user._id }, { chair: req.user._id }],
  }).sort({ status: 1, date: 1 });
  const taskMetas = await batchUserTasks(req, Task.find().stream());
  const tasks = await prepareTasks(taskMetas, req.user._id);

here is complete code:

  paste.ofcode.org/fxJESwAgM8iHc6RhF4a6AR
alpha dev
  • 21
  • 1
  • 8
  • Does this answer your question? [How to select a single field for all documents in a MongoDB collection?](https://stackoverflow.com/questions/25589113/how-to-select-a-single-field-for-all-documents-in-a-mongodb-collection) – Anshuman Jun 14 '20 at 07:25
  • https://stackoverflow.com/q/25589113 Did you check it? – Anshuman Jun 14 '20 at 07:25
  • @anshuman i add id into above code ""const taskMetas = await batchUserTasks( req, Task.find({ chair: req.user._id }).stream());"" but it says "meeting_sliders_scripts.js:53 Uncaught TypeError: Cannot read property '_id' of undefined" error line in code which is showing in sources is "streamTasks(tasks[tasks.length - 1]._id);" – alpha dev Jun 14 '20 at 07:34
  • @anshuman https://ibb.co/VQxDrrr https://ibb.co/64q2y77 https://ibb.co/v3w1sxP – alpha dev Jun 14 '20 at 07:38

0 Answers0