Skip to content

Time travelling example in Typescript seems wrong #27498

@finalyards

Description

@finalyards

Existing documentation URL(s)

https://developers.cloudflare.com/durable-objects/api/sqlite-storage-api/#onnextsessionrestorebookmark

What changes are you suggesting?

The "restore 2 days ago" doesn't seem right in Typescript.

let now = new Date();
// restore to 2 days ago
let bookmark = ctx.storage.getBookmarkForTime(now - 2);  // <-- 2ms
ctx.storage.onNextSessionRestoreBookmark(bookmark);

I'd use let bookmark = ctx.storage.getBookmarkForTime( new Date(now - (2 * 24 * 60 * 60 * 1000)) ), with or without the new Date. The current code substracts mere 2 milliseconds and also converts bookmark to be a number (which may be intended, not sure).

This is of course minor. Most people will realize to use the right syntax - I'm very impressed with the quality of Cloudflare's documentation.

Additional information

No response

Metadata

Metadata

Labels

content:editRequest for content editsdocumentationDocumentation editsproduct:durable-objectsDurable Objects: https://developers.cloudflare.com/workers/learning/using-durable-objects/

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions