Похожие чаты

Can anyone help...

foundUser.currentPlan.hasActivePlan = false
foundUser.expiredPlans.push(foundUser.currentPlan)

if (foundUser.upcomingPlan[0]) {
if (foundUser.upcomingPlan[0].hasUpcomingPlan) {
console.log("adding upcoming plan to current plan");
foundUser.currentPlan.hasActivePlan = true
foundUser.currentPlan.validity = foundUser.upcomingPlan[0].validity
foundUser.currentPlan.planActivationDate = moment().format("DD/MM/YYYY HH:mm:ss")
foundUser.currentPlan.expireyDate = moment().add(foundUser.upcomingPlan[0].validity, 'days').format("DD/MM/YYYY HH:mm:ss")
foundUser.currentPlan.amount = foundUser.upcomingPlan[0].amount
foundUser.upcomingPlan.shift()
}
}


foundUser.save()

Here you can see (in bold text) first i'm trying to push old value of founduser.currentplan in foundUser.expiredplans and after that if upcomingplans exists then updating the founduser.currentplan with different values and later saving it using foundUser.save().
My problem is that if the condition is true then instead of saving old values of currentplan in expiredplans it is saving new values to it. How to solve it??

5 ответов

7 просмотров

It's a MongoDB code

Daniel
Whats wrong with that?

DB driver shouldn't really be doing it

Thomas
DB driver shouldn't really be doing it

I don't know where the Database driver does it. He only uses .save() from the Database driver.

Похожие вопросы

Обсуждают сегодня

Типа вызывать GetParent и проверять на соответствие GetModuleHandle?
The Bird of Hermes
67
Do any of you guys have interesting projects one could join? I'm a Middle Full-Stack developer (JS/TS, React & Node)
Lev Shapiro
40
$res = json_decode($наша строка из респонса); $res1 = array_map(fn($o) => $o->name, $res->breadcrumbs[0]->entities); Как такое будет на Хаскеле?.. В начале весь джейсон, в ко...
Хаскель Моисеевич Гопник
27
I read yesterday that in the near future most cryptos will be gone. It's like there is a lot of bullshit within the crypto sphere and this corruption some way is going to be c...
Kanah The Great
41
Hello, I have a question. Can anyone help me? I want to make my cryptocurrencies, like Tron, untraceable by anyone, even government organizations. I was told that to do this,...
 ➛ Eᒪᕼᗩᗰ
14
В чем сила брат, в NASM или FASM?
Isaac Kleiner
18
Вопрос по диагностике ошибок (я знаю в чем, в данном конкретном примере, я знаю, как исправить, пример модельный, понятно, что в реальности бывает намного запутаннее). module...
ⰄⰎⰋⰐⰐⰑⰛⰤⰧⰧⰩⰄ ⰊⰑⰁⰓⰡⰛⰦⰕⰫ
11
Хтось використовував Vapor на Windows?
Jaroshevskii
15
It's notoriously hard to unit test video games, because they rely on user input so much and their output is audiovisual content. Does that mean video game code is never mainta...
Thomas
10
Hi Everybody I bought BCH when it’s 600 and I’m new in crypto what should I do ?
Khush
12
Карта сайта