Is there some way to update an optional DateTime t...
# orm-help
r
Is there some way to update an optional DateTime to
now()
? Can't use
@updatedAt
since there's nothing else to update. Currently I'm setting it to
new Date()
but that comes from the client which might be not in sync with the server's time.
d
@updatedAt
r
I tried that but it did not update anything with
data: { }
.
Do I need to do some dummy/no-op update?
That's what it looks like:
Copy code
start  DateTime  @default(now())
end    DateTime?
Copy code
... create: { } // start = now(), end = null
... updateMany: { data: { end: new Date() }, where: { end: null } } // end should be set to now() as well
Copy code
start  DateTime  @default(now())
end    DateTime? @updatedAt
Copy code
... create: { end: null } // start = now(), end = null
... updateMany: { data: { }, where: { end: null } } // end is not updated :(
r
@Ralf Vogler 👋 Answered here 🙂
r
Thanks, but the problem remains.
updatedAt
for an optional date does not seem to update
null
. Also, w/o a symbol for
now()
this will always be a problem if the query is built on a different device.