I am trying to set check_date
to null
I tried
new Date as 0, null
but none of them are working for me. How can I achieve this?
Code
async lastDayToLive() {
const allDiner = await this.amazon.findAll({ where: { flight: 'L' } });
const len = allDiner .length;
const lastDinker = allDiner [len - 1];
const { a,} = lastDinker;
await this.amazon.update(
{ flight: 'land', check_date: `${new Date(0)}` }, --------------------> Here
{ where: {a}}
);
}
I am trying to set check_date
to null
I tried
new Date as 0, null
but none of them are working for me. How can I achieve this?
Code
async lastDayToLive() {
const allDiner = await this.amazon.findAll({ where: { flight: 'L' } });
const len = allDiner .length;
const lastDinker = allDiner [len - 1];
const { a,} = lastDinker;
await this.amazon.update(
{ flight: 'land', check_date: `${new Date(0)}` }, --------------------> Here
{ where: {a}}
);
}
Share
Improve this question
edited Mar 4, 2021 at 18:03
Paritosh M
asked Mar 4, 2021 at 17:21
Paritosh MParitosh M
3792 gold badges6 silver badges19 bronze badges
3
-
2
How is this not working:
check_date: null
? – codemonkey Commented Mar 4, 2021 at 17:26 -
1
But do you mean by "not working"? Do you mean whatever you pass that object to is not doing what it's supposed to? Because
check_date: null
will setcheck_date
tonull
, no question about it. – codemonkey Commented Mar 4, 2021 at 17:28 -
The issue is clearly not here:
{ flight: 'land', check_date: null }
. It's somewhere up the pipeline. – codemonkey Commented Mar 4, 2021 at 17:49
1 Answer
Reset to default 4You can't set a Date to null
. Date is an an embedded JavaScript type.
Setting date to new Date(0)
just sets it to Unix Epoch.
You can, however, set a variable to null
.
This should work:
var check_date = null;
or, in your case:
await this.amazon.update(
{ flight: 'land', check_date: null },
{ where: {a}}
);