How big is your app? What kind of data are you storing? How many reads/writes are you doing?
How big is your app? What kind of data are you storing? How many reads/writes are you doing?
pivot or crosstab queries, calendar querying (for the type of data I'm dealing with) is very complex. I'd like to try a different approach. One column per day per resource with the value of the availability stored as a tinyint.SELECT id FROM projects WHERE url = ? then SELECT something FROM metadata WHERE id = ? using that ID (where there could be multiple somethings in the latter table).
The Cache API can be thought of as an ephemeral key-value store, whereby the Request object (or more specifically, the request URL) is the key, and the Response is the value.

.get(key) and .put(key,value)EXPLAIN QUERY PLAN SELECT * FROM objects WHERE object = '${key}' and it'll tell you what it's doingpivotcrosstabtinyintSELECT id FROM projects WHERE url = ?SELECT something FROM metadata WHERE id = ?somethingTo execute a transaction, please use the state.storage.transaction() API instead of the SQL BEGIN TRANSACTION or SAVEPOINT statements. The JavaScript API is safer because it will automatically roll back on exceptions, and because it interacts correctly with Durable Objects' automatic atomic write coalescing.
Error: D1_ERROR: not authorized
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)export const user = sqliteTable('user', {
id: integer('id').notNull().primaryKey(),
avatarId: text('avatar_id', { mode: 'text', length: 255 }),
});export const user = sqliteTable('user', {
id: integer('id').notNull().primaryKey(),
avatarId: integer('avatar_id').references(() => media.id, { onDelete: 'set null' }),
});
// ...
export const media = sqliteTable('media', {
id: integer('id').notNull().primaryKey(),
createdAt: integer('created_at', { mode: 'timestamp' })
.notNull()
.default(sql`(unixepoch())`),
updatedAt: integer('updated_at', { mode: 'timestamp' })
.notNull()
.default(sql`(unixepoch())`),
fileName: text('file_name', { mode: 'text', length: 255 }).notNull(),
mediaType: text('file_type', { mode: 'text' }).notNull(),
mimeType: text('mime_type', { mode: 'text', length: 100 }).notNull(),
size: integer('size', { mode: 'number' }).notNull(),
width: integer('width', { mode: 'number' }).notNull(),
height: integer('height', { mode: 'number' }).notNull(),
src: text('src', { mode: 'text' }).notNull(),
srcSet: text('srcset').notNull(),
alt: text('alt', { mode: 'text' }).notNull(),
});