Exercise tracker logs

const mongoose = require("mongoose");

const UserSchema = new mongoose.Schema({
  username: { type: String, required: true },
  count: { type: Number, default: 0 },
  log: [
    {
      description: String,
      duration: Number,
      date: { type: Date, default: Date.now },
    },
  ],
});

const UserModel = mongoose.model("User", UserSchema);

Let’s say I have a user with this type of schema and I want to query all the exercises in the log array with a from(date), to(date) and a limit… So I can filter out the elements in the array that have their date falling between that date range (from and to) and also set a limit to the number of elements I can return… Can anyone help?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.