-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs feature branch: SQLite in DO #16903
Conversation
Deploying cloudflare-docs with Cloudflare Pages
|
We're going to use
@harshil1712 Could you work on adding an example or even multiple? Kenton's example in the public blog should be available in docs as well. |
// query returned zero results | ||
} | ||
|
||
console.log(cursor.toArray()); // prints [{ artistid: 456, artistname: 'Bob' },{ artistid: 789, artistname: 'Charlie' }] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that this example is showing multiple things, but it seems kinda weird to have cursor.toArray() in this example. It would be better to have individual examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returned cursor and
raw()
iterator iterate over the same query results and can be combined.
Wanted this example embedded here to highlight the above bullet.
There are individual examples for different tasks below on this page
src/content/docs/durable-objects/best-practices/access-durable-objects-storage.mdx
Outdated
Show resolved
Hide resolved
src/content/docs/durable-objects/best-practices/access-durable-objects-storage.mdx
Outdated
Show resolved
Hide resolved
|
||
Durable Objects are a powerful compute API that provides a compute with storage building block. Each Durable Object has private, transactional and strongly consistent storage attached. By default, key-value storage is available. SQL storage(/durable-objects/best-practices/access-durable-objects-storage/#sql-storage) is available on a new beta version of Durable Objects. | ||
|
||
You should use Durable Objects storage to persist state durably on-disk that needs to survive beyond the lifetime of a Durable Object, that is, eviction of a Durable Object from memory. A Durable Object is alive based on the request traffic incoming to the instance. There are also normal operations like [code deployments](/workers/configuration/versions-and-deployments/) that trigger a Durable Object to reset. For these reasons, Durable Objects storage is recommended for persisting [in-memory state](/durable-objects/reference/in-memory-state/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what this paragraph is trying to tell me.
I think it's trying to make the distinction between in-memory and on-disk storage, but that doesn't follow from the first paragraph. Perhaps the first paragraph needs to mention that DOs persist across requests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reworked, lmk if it helped.
Co-authored-by: justin-mp <[email protected]>
|
||
**D1 is a managed database product.** | ||
|
||
D1 fits into a familiar architecture for developers, where application servers communicate with a database over the network. Application servers are typically Workers; however, D1 also supports external, non-Worker access via an [HTTP API](https://developers.cloudflare.com/api/operations/cloudflare-d1-query-database). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think it's a missed opportunity not to highlight the framework support that D1 has and that DO probably cannot have.
I have no idea where this comment went, but @vy-ton asked
This defines |
src/content/docs/durable-objects/best-practices/access-durable-objects-storage.mdx
Outdated
Show resolved
Hide resolved
src/content/docs/durable-objects/best-practices/access-durable-objects-storage.mdx
Outdated
Show resolved
Hide resolved
Co-authored-by: Jun Lee <[email protected]> Co-authored-by: justin-mp <[email protected]>
SQLite in DO docs --------- Co-authored-by: Kenton Varda <[email protected]> Co-authored-by: justin-mp <[email protected]> Co-authored-by: Jun Lee <[email protected]>
SQLite in DO docs --------- Co-authored-by: Kenton Varda <[email protected]> Co-authored-by: justin-mp <[email protected]> Co-authored-by: Jun Lee <[email protected]>
TODO:
new_sqlite_classes
TODO unrelated to SQLite-in-DO:
script_name
in the binding)Later PR:
/durable-objects/build/scaling-durable-objects/
doc that talks about how to scale horizontally, data model, and manage DOs. @elithrar