Any comment regarding this? https://discord.com/channels/595317990191398933/992060581832032316/11384

Any comment regarding this? d1-database
To rephrase: if D1 is built on top of DO, then why is it so much cheaper?

Interestingly enough, I can wrap my D1 calls into DO transactions like that and it seems to work fine

    const value = 0;
    let d1Response: any;
    await this.state.storage.transaction(async (txn) => {
      try {
        txn.put('value', this.value);
        const stmt = this.db
          .prepare(`INSERT INTO items (itemData) VALUES (?) RETURNING *`)
          .bind(JSON.stringify({ value }));
        d1Response = await stmt.all();
      } catch (e) {
        console.error(e);
        txn.rollback();
        throw e;
      }
    });

but I wouldn't want to do this just for cost management purposes
Was this page helpful?