Deno KV Type Error
When I run await (await kv.get<typeThing>(["example"])).id (the value is an object), it returns a type error because it is a maybe type thing.
7 Replies
The error:
Perhaps the problem changed.
The top is the problem.
Although I check that
await kv.get<typeThing>(["example"]) != null
, with an if statement, it still does not get rid of the error.Cool.
This is not different from
!= null
.You could do (result !== null)
Be aware that the object returned by the promise
KvEntryMaybe = {key, value, versionstamp}
, will always return the key, but if not found, both the value, and the timestamp will be null.Oh, okay.
Thanks.
Also, as someone could insert a row with the value set to
null
, it might be best to check the versionstamp for null, rather than the value. Be aware that some folks might just use the multipart key as both key and data, and just put null in the value field.This doesn't work.
Even when doing the if statement + the result declaration.
Nvm.