https://discord.cloudflare.com logo
Join Discord
Powered by
# d1-open-alpha
  • u

    Unsmart | Tech debt

    05/27/2023, 7:32 PM
    Ah interesting that would’ve been after I started using it 😅
  • n

    nora

    05/27/2023, 7:33 PM
    https://developers.cloudflare.com/d1/platform/client-api/#return-object should
    success
    always be assumed to be true then?
  • e

    elithrar

    05/27/2023, 7:34 PM
    You should handle the false case - let me take an action to iterate over the failure modes more explicitly
  • c

    connor

    05/28/2023, 2:37 AM
    Using Wrangler in my CI and when migrations fail it is still exiting cleanly. Wondering if it's something I'm doing wrong or if that's an issue with wrangler

    https://cdn.discordapp.com/attachments/992060581832032316/1112207881962532883/image.png▾

  • w

    Walshy | Pages

    05/28/2023, 2:38 AM
    looks like a wrangler bug, not seeing us exit with code 1: can you file an issue on the wrangler repo?
  • c

    connor

    05/28/2023, 2:38 AM
    for sure :)
  • c

    connor

    05/28/2023, 2:41 AM
    https://github.com/cloudflare/workers-sdk/issues/3365
  • s

    Skye

    05/28/2023, 8:39 AM
    There's a PR to fix this at , fyi 🙂
  • c

    connor

    05/28/2023, 11:35 AM
    aaaa, good spot. ty
  • c

    connor

    05/28/2023, 11:35 AM
    hopefully it gets merged soonish :)
  • p

    Phong

    05/28/2023, 2:07 PM
    Could we use D1 with prisma?
  • j

    James

    05/28/2023, 2:14 PM
    Not yet, but hopefully soon!
  • p

    Phong

    05/28/2023, 2:19 PM
    This issue has opened more than 1 year 😅 But hope it soon
  • e

    elithrar

    05/28/2023, 4:33 PM
    That issue was opened before D1 was even in open alpha, which was probably… a little premature 🙂 (We’re close with the Prisma folks so expect something soon)
  • l

    lokiwind

    05/28/2023, 11:12 PM
    There is 1 table and only 4 ip addresses are registered in this table. Showing 65kb data. What's the reason for that?

    https://cdn.discordapp.com/attachments/992060581832032316/1112518702693355550/Screenshot_11.png▾

  • l

    lokiwind

    05/28/2023, 11:13 PM
    Size of the database with no tables created

    https://cdn.discordapp.com/attachments/992060581832032316/1112519057812500560/Screenshot_12.png▾

  • g

    geelen

    05/29/2023, 12:41 AM
    usually it's just sqlite's own internal structure taking up some space. Can be slightly higher if you've created then deleted tables. I think the smallest sqlite DB is 4kb, once you have at least one table (even with no data) it's 8kb, that sort of thing.
  • g

    geelen

    05/29/2023, 12:44 AM
    You might find that if you were to create a table and insert 3kb of data that that 49KB value doesn't change, since it's reusing space it's already made room for rather than growing.
  • g

    geelen

    05/29/2023, 12:44 AM
    in general sqlite is really efficient, but it's not perfect
  • b

    biscuit

    05/29/2023, 2:39 AM
    Just want to say AMAZING work on the new update D1 devs 🔥🔥🔥
  • b

    biscuit

    05/29/2023, 2:43 AM
    Copy code
    Developers with existing databases can import data into a new database backed by the storage engine by following the steps to export their database and then import it in our docs.
    Do I have to do this for my 2 month old D1 database or should I export and import again, I saw a difference of over 2x currently so i assumed it automatically updated to the new storage system
  • CREATE TRIGGER support in D1?
    m

    momiller121

    11/28/2023, 6:22 PM
    SQLite supports database triggers via CREATE TRIGGER[https://www.sqlite.org/lang_createtrigger.html]. Is this capability supported in D1? My experimentation with it (so far) shows that D1 will accept the schema to create the trigger, but I have yet to see evidence of the trigger functioning. It's either my error or it's not implemented internally. I'm not sure which.
    g
    • 2
    • 1
  • D1_ERROR: Cannot resolve D1 due to transient issue on remote node
    m

    milanmk18

    12/06/2023, 3:39 AM
    I am getting the following error couple of times a day while running a simple
    await stmt.first([column])
    command.
    Copy code
    Error: D1_ERROR: Cannot resolve D1 due to transient issue on remote node.
    at D1Database._sendOrThrow (cloudflare-internal:d1-api:66:19)
    at async D1PreparedStatement.first (cloudflare-internal:d1-api:153:35)
    at async Object.fetch (worker.js:86:26)
    u
    • 2
    • 2
  • greetings! is there a way to import JSON
    g

    G4G4N

    12/25/2023, 4:39 AM
    1. MongoDB compass export to JSON. 2. https://konbert.com/convert/json/to/sqlite converts JSON to SQL queries to import data to D1 database.
    g
    • 2
    • 2
  • I'm getting `Error: D1_ERROR: database
    c

    Cole Xemi

    12/31/2023, 8:03 PM
    I fixed this by running a rebuild on my FTS5 index. I wonder if something got messed up from my side
  • How do you get the primary key of the
    c

    Cole Xemi

    12/31/2023, 10:08 PM
    Add
    returning
    to your query to return.
    first
    just returns the first item of the result
    • 1
    • 1
  • Read replication
    v

    vaiton13

    01/02/2024, 9:35 PM
    Product Manager working on D1 here. As Cloudflare is designing D1's read replication, I'd like to chat with some folks to validate different aspects. If you're interested, please drop a comment in this thread.
    d
    s
    +3
    • 6
    • 18
  • @TigersWay Retry is definitely
    t

    TigersWay

    01/04/2024, 9:35 PM
    Thank you @Vy for that question! There's 3 potential requests in this workload which is supposed to record a website visitors: - the first one and only one when it happens, is a simple insert (in case of bot), - the second is a heavy insert with 24 fields (details of the visitor) - the third is a simple insert again to log errors on the second one That second one is the one in trouble, but nothing except the size of data (url, path, user-agent,etc) is exceptional.
    v
    • 2
    • 7
  • D1 Regional Latency
    a

    AaronO

    01/08/2024, 4:48 PM
    Copy code
    json
    [
      {
        "id": "73aa3745312b9d77a2ebc620c256afd511c6d77678c01cc5e4a7195c9577510d",
        "duration": 0.1758,
        "latency": 49,
        "latency2": 70,
        "code": "wnam",
        "name": "Western North America"
      },
      {
        "id": "e752bbc411591eb378db5f361b1b1619d873117f53f198332aa5248314f627f4",
        "duration": 0.1888,
        "latency": 153,
        "latency2": 294,
        "code": "enam",
        "name": "Eastern North America"
      },
      {
        "id": "753dc6fe394b9cb0308ace1ade131b43a1692a55d6834e8701a01909eb9fea9b",
        "duration": 0.1416,
        "latency": 131,
        "latency2": 198,
        "code": "sam",
        "name": "South America"
      },
      {
        "id": "d2e25bd9658e42df959504fac5dffd8d83fb8e2366dc6ac06ec2d84831b4dc37",
        "duration": 0.0735,
        "latency": 325,
        "latency2": 480,
        "code": "weur",
        "name": "Western Europe"
      },
      {
        "id": "e31627d610192131b70d0045008206b30c9cf01ca84fe2c9b1c27cf96d5d8c8e",
        "duration": 0.1483,
        "latency": 319,
        "latency2": 486,
        "code": "eeur",
        "name": "Eastern Europe"
      },
      {
        "id": "5f64af3a6faf1dd70be9ac26d6cd41bf89d0c0a1a6d6207b0119514492b4a7f4",
        "duration": 0.1706,
        "latency": 256,
        "latency2": 387,
        "code": "apac",
        "name": "Asia-Pacific"
      },
      {
        "id": "10a82824d9f8cb7278cf5f4abe3638b448b9d728d7de77bbbdfb72d0407a4494",
        "duration": 0.218,
        "latency": 259,
        "latency2": 389,
        "code": "oc",
        "name": "Oceania"
      },
      {
        "id": "6f2b7986d114370dcd2b42c89733e18fe53007d9f7a38f132bd1e85a82a01394",
        "duration": 0.1178,
        "latency": 322,
        "latency2": 486,
        "code": "afr",
        "name": "Africa"
      },
      {
        "id": "2e93bd640ad96a643cfa7160f9f4d6f256c8bba512bf0b344ef0cbe88e791d12",
        "duration": 0.1582,
        "latency": 303,
        "latency2": 455,
        "code": "me",
        "name": "Middle East"
      }
    ]
    g
    • 2
    • 3
  • if i have an array of primary keys, how
    g

    G4G4N

    01/10/2024, 11:51 PM
    solved it by doing something like: // Generate placeholders let placeholders = activeUserIds.map((_, index) => '?' + (index + 1)).join(',') // Use placeholders in the query and bind values const { results: guests } = await this.env.DB.prepare(
    Copy code
    SELECT user.*, plan.planTier 
                    FROM user
                    LEFT JOIN plan ON user._id = plan.userId 
                    WHERE user._id IN (${placeholders})
    ) .bind(...activeUserIds) .all()