Похожие чаты

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 ответов

14 просмотров

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.

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

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

VIP-397 BNBx Oracle implementation upgrade Summary This proposal, if approved, will upgrade the implementation of the BNBx Oracle contract on Venus from version 1 (V1) to v...
Venus Announcements
2
Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
Ну вот просто даже давайте вот как. Какой нибудь конкретный кейс, можете в пример привести, где бч работает и приносит прикладную пользу, а не просто что бы было? Не крипту.
Alexander Andreev
22
For all those that keep asking why no pump? why this ? and why that...? Please close ur ewt chart and open 2 others - TOTAL (total mc) and BTC.D (btc dominance). Maybe BTC a...
Inn3r_G
19
объясните пожалуйста, почему функция не работает должным образом? вроде должно брать активное окно сравнивать его размер с размером экрана, и если есть совпадение = true прове...
JF
12
"Since pnut can flip FTM easily, I'm swapping my FTM to pnut and hoping for a easy x5-x10" Perfect recipe for disaster. NFA but chances are, you'll end up as exit liquidity ...
C. A.
7
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
Hi mates I have recently started to study cyber security and as I understood that strong server side validation is tough enemy for hackers, so which tools of encoding - obfus...
Börke(МБорке)
8
AMD status update? No longer in the plan but something might be around the corner later on Chinese partner? No longer in the plan. This market does not seem to be the top ...
Ben
6
207$ but only received 170$. what the hell?
htt
10
Карта сайта