• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

129
Views
I can't edit the object on mongo database

So i am trying to check if the user has the object with id: 1 after that i try to edit values of this object but it doesn't edit it!

I tried to console.log(quest) and it logged the quest object

       let data;
        try{
            data = await schema.findOne({
                userID: message.author.id
            })
            if(!data) {
            data = await schema.create({
                userID: message.author.id
            })
            }
        } catch(err) {
            console.log(err)
        }

        const quest = data.progress.quests.find(x => x.id == 1)
        quest.current++
        await data.save()

This is how quests array looks in the database

[
    {
        "name": "Say Hi in chat",
        "progress": 5,
        "current": 0,
        "id": 1,
        "reward": 500
    },
    {
        "name": "Play video games",
        "progress": 10,
        "current": 0,
        "id": 2,
        "reward": 250
    },
    {
        "name": "Walk for a time",
        "progress": 5,
        "current": 0,
        "id": 3,
        "reward": 250
    }
]
about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error