hello here,this change about `.run` I

hello here,this change about .run I have updated the types and wrangler and I still see that run returns a D1Response. What I am missing?
7 Replies
Sébastien Morel
Sébastien MorelOP•10mo ago
we are using Beta by default right ? https://github.com/cloudflare/workerd/blob/a8b68b397aa7466e551011016a94da35d81abc4a/types/defines/d1.d.ts#L37 no hint @nora ? but the doc says we should receive a D1ExecResult asking because of error actually that is in D1Response but not in D1ExecResult and was in D1Result 🙂 sure let me reopen that quickly and dumping here so I am using last version of wrangler
{
results: '{\n' +
' "success": true,\n' +
' "meta": {\n' +
' "served_by": "miniflare.db",\n' +
' "duration": 1,\n' +
' "changes": 1,\n' +
' "last_row_id": 0,\n' +
' "changed_db": true,\n' +
' "size_after": 32768,\n' +
' "rows_read": 1,\n' +
' "rows_written": 5\n' +
' },\n' +
' "results": []\n' +
'}'
}
{
results: '{\n' +
' "success": true,\n' +
' "meta": {\n' +
' "served_by": "miniflare.db",\n' +
' "duration": 1,\n' +
' "changes": 1,\n' +
' "last_row_id": 0,\n' +
' "changed_db": true,\n' +
' "size_after": 32768,\n' +
' "rows_read": 1,\n' +
' "rows_written": 5\n' +
' },\n' +
' "results": []\n' +
'}'
}
want me to do that in production ? results of this code
const results = await db
.prepare(query)
.bind(...values)
.run()
console.log({ results: JSON.stringify(results, undefined, 2) });
const results = await db
.prepare(query)
.bind(...values)
.run()
console.log({ results: JSON.stringify(results, undefined, 2) });
checking now could it be that wrangler is not up-to-date or something ? because it seems to be the whole point of the changeset
{
"message": [
{
"results": "{\n \"success\": true,\n \"meta\": {\n \"served_by\": \"v3-prod\",\n \"duration\": 0.2824,\n \"changes\": 1,\n \"last_row_id\": 0,\n \"changed_db\": true,\n \"size_after\": 47980544,\n \"rows_read\": 1,\n \"rows_written\": 7\n }\n}"
}
],
"level": "log",
"timestamp": 1707936785925
},
{
"message": [
{
"results": "{\n \"success\": true,\n \"meta\": {\n \"served_by\": \"v3-prod\",\n \"duration\": 0.2824,\n \"changes\": 1,\n \"last_row_id\": 0,\n \"changed_db\": true,\n \"size_after\": 47980544,\n \"rows_read\": 1,\n \"rows_written\": 7\n }\n}"
}
],
"level": "log",
"timestamp": 1707936785925
},
so I guess the issue is in the Types and Wrangler, they have not been updated so doc is ok compare to prod, it's just that as a developer it does not reflect locally I guess we should code in production then haha nop, in prod, there is no results and there is duration which matches the changelog in the doc do you know how this stuff is synchronized between wrangler and the types and what happen in production?. I mean I do know it's beta so I am not complaining. Just want to understand where I can track those stuff (pretty new in the ecosystem of Cloudflare) but that does make sense right, it's possible that is just wrangler/types that is not up to date?
elithrar
elithrar•10mo ago
The types are not up-to-date (the docs are). @geelen is working on publishing updated types.
Sébastien Morel
Sébastien MorelOP•10mo ago
I see, well all good then! thanks !
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
Sébastien Morel
Sébastien MorelOP•10mo ago
I did update to that version yes I don't think that's updated though on your side: https://github.com/cloudflare/workerd/blob/a8b68b397aa7466e551011016a94da35d81abc4a/types/defines/d1.d.ts#L37 cc @geelen
Unknown User
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
Sébastien Morel
Sébastien MorelOP•10mo ago
yes (no a real problem right) but indeed dev is not running in a prod-like env 🙂
Want results from more Discord servers?
Add your server