#MONGODB CLUSTER

35 messages · Page 1 of 1 (latest)

hushed zinc

I tried like this, but I just didn't want the numbers (0, 1), because it will have more values

obtuse anchor

Huh? That’s just how arrays work…

hushed zinc
obtuse anchor

Huh? What do you want to stop there?

hushed zinc
obtuse anchor

You literally do… but arrays always do contain stuff indexed by numbers. The numbers you see there aren’t values inside the array, they only are the indexes of the values

hushed zinc

And what returns from currentPageData.name, is in the database

obtuse anchor
spice frigateBOT

mdn Array.prototype.includes()
The includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate.

hushed zinc

It works, but imagine that I just added the value and then I check and it returns the empty array and if I restart the bot it appears in the array

I'm using $push has something to do with it, why not save it right away?

obtuse anchor

It does save right away (in db), but you probably don’t update the variable you got from DB earlier

hushed zinc

It's like this right now, how do I fix it?

obtuse anchor

Depends, how and where did you declare User and how and where do you try to access it without it having the newly updated skins?

hushed zinc
obtuse anchor

I won‘t be able to help you if you keep on sending screenshots of single lines of your code without context…

spice frigateBOT

To share long code snippets use a service like gist, sourcebin, starbin, or similar instead of posting them as large code blocks.

hushed zinc

SOrry

obtuse anchor

Then you‘d need to reassign User after you updated in DB to the updated value

Not sure if findOneAndUpdate returns the updated document, if it does just do User = UserModel.findOneAndUpdate(…)
If not you need to findOne after that update call

hushed zinc

I did it like this and it worked

Thank you

stiff belfry

In mongoose you can return updated DBs as new: true

const DB = await nameOfSheama.findOneAndUpdate(
{ id: idToFind },
{update: update},
{new: true}
)

console.log(DB.update) // updated value
left snow

If one not. Made do

Mongodb.create({ stuff to make here )}

hushed zinc

MONGODB CLUSTER