My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

MongoDB: How to change data in db on a specific day and time?

Argjend's photo
Argjend
·Jan 8, 2017

I have a specific requirment for a web application which is build with Nodejs/MongoDb/Express/Angular. Application itself is a application for mentors and has a kind of schema like this:

var userSchema = new mongoose.Schema({
    email: {
        type: String,
        unique: true,
        required: true
    },

         username: {
        type: String,
        unique: true,
        required: true
    },
        ....

        status: {type: String, enum: ["online", "offline"]},
        schedule: [{
            day: String,
            StartTime: Date,
            EndTime: Date
        }]

                ...


        })

Every user has its own schedule, for example working Every: Monday ,Wednesday ,Thursday From: 04:00 PM To: 07:00 PM.

Now, how can I change the status from Offline to Online as they submited their schedule. I mean from the example above, to change Every: Monday ,Wednesday ,Thursday at the specific time the user status on db from "offline" to "online" ?

Thanks