Skip to content
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

Add batch support #10361

Merged
merged 7 commits into from
Mar 7, 2024
Merged

Add batch support #10361

merged 7 commits into from
Mar 7, 2024

Conversation

bholmesdev
Copy link
Contributor

Changes

Add support for db.batch() to run multiple queries in a single transaction.

  • Bump Drizzle to 0.29.5 (minor bump)
  • Implement batching for the remote adapter. Nothing to do for local

Testing

  • Add db.batch() call to basics test fixture

Docs

N/A

Copy link

changeset-bot bot commented Mar 7, 2024

🦋 Changeset detected

Latest commit: 0f02294

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@bholmesdev bholmesdev marked this pull request as draft March 7, 2024 18:30
@bholmesdev
Copy link
Contributor Author

!preview db-batch

@bholmesdev bholmesdev marked this pull request as ready for review March 7, 2024 18:42
Copy link
Contributor

github-actions bot commented Mar 7, 2024

Snapshots have been released for the following packages:

  • @astrojs/db@experimental--db-batch
  • create-astro@experimental--db-batch
  • astro@experimental--db-batch
Publish Log
🦋  warn ===============================IMPORTANT!===============================
🦋  warn Packages will be released under the experimental--db-batch tag
🦋  warn ----------------------------------------------------------------------
🦋  info npm info astro
🦋  info npm info @astrojs/prism
🦋  info npm info @astrojs/rss
🦋  info npm info create-astro
🦋  info npm info @astrojs/db
🦋  info npm info @astrojs/alpinejs
🦋  info npm info @astrojs/lit
🦋  info npm info @astrojs/markdoc
🦋  info npm info @astrojs/mdx
🦋  info npm info @astrojs/node
🦋  info npm info @astrojs/partytown
🦋  info npm info @astrojs/preact
🦋  info npm info @astrojs/react
🦋  info npm info @astrojs/sitemap
🦋  info npm info @astrojs/solid-js
🦋  info npm info @astrojs/svelte
🦋  info npm info @astrojs/tailwind
🦋  info npm info @astrojs/vercel
🦋  info npm info @astrojs/vue
🦋  info npm info @astrojs/internal-helpers
🦋  info npm info @astrojs/markdown-remark
🦋  info npm info @astrojs/telemetry
🦋  info npm info @astrojs/underscore-redirects
🦋  info npm info @astrojs/upgrade
🦋  info astro is being published because our local version (0.0.0-db-batch-20240307184301) has not been published on npm
🦋  warn @astrojs/prism is not being published because version 3.0.0 is already published on npm
🦋  warn @astrojs/rss is not being published because version 4.0.5 is already published on npm
🦋  info create-astro is being published because our local version (0.0.0-db-batch-20240307184301) has not been published on npm
🦋  info @astrojs/db is being published because our local version (0.0.0-db-batch-20240307184301) has not been published on npm
🦋  warn @astrojs/alpinejs is not being published because version 0.4.0 is already published on npm
🦋  warn @astrojs/lit is not being published because version 4.0.1 is already published on npm
🦋  warn @astrojs/markdoc is not being published because version 0.9.1 is already published on npm
🦋  warn @astrojs/mdx is not being published because version 2.1.1 is already published on npm
🦋  warn @astrojs/node is not being published because version 8.2.3 is already published on npm
🦋  warn @astrojs/partytown is not being published because version 2.0.4 is already published on npm
🦋  warn @astrojs/preact is not being published because version 3.1.1 is already published on npm
🦋  warn @astrojs/react is not being published because version 3.0.10 is already published on npm
🦋  warn @astrojs/sitemap is not being published because version 3.1.1 is already published on npm
🦋  warn @astrojs/solid-js is not being published because version 4.0.1 is already published on npm
🦋  warn @astrojs/svelte is not being published because version 5.2.0 is already published on npm
🦋  warn @astrojs/tailwind is not being published because version 5.1.0 is already published on npm
🦋  warn @astrojs/vercel is not being published because version 7.3.5 is already published on npm
🦋  warn @astrojs/vue is not being published because version 4.0.8 is already published on npm
🦋  warn @astrojs/internal-helpers is not being published because version 0.2.1 is already published on npm
🦋  warn @astrojs/markdown-remark is not being published because version 4.2.1 is already published on npm
🦋  warn @astrojs/telemetry is not being published because version 3.0.4 is already published on npm
🦋  warn @astrojs/underscore-redirects is not being published because version 0.3.3 is already published on npm
🦋  warn @astrojs/upgrade is not being published because version 0.2.3 is already published on npm
🦋  info Publishing "astro" at "0.0.0-db-batch-20240307184301"
🦋  info Publishing "create-astro" at "0.0.0-db-batch-20240307184301"
🦋  info Publishing "@astrojs/db" at "0.0.0-db-batch-20240307184301"
🦋  success packages published successfully:
🦋  astro@0.0.0-db-batch-20240307184301
🦋  create-astro@0.0.0-db-batch-20240307184301
🦋  @astrojs/db@0.0.0-db-batch-20240307184301
🦋  Creating git tags...
🦋  New tag:  astro@0.0.0-db-batch-20240307184301
🦋  New tag:  create-astro@0.0.0-db-batch-20240307184301
🦋  New tag:  @astrojs/db@0.0.0-db-batch-20240307184301
Build Log

> root@0.0.0 build /home/runner/work/astro/astro
> turbo run build --filter=astro --filter=create-astro --filter="@astrojs/*" --filter="@benchmark/*"

• Packages in scope: @astrojs/alpinejs, @astrojs/cloudflare, @astrojs/db, @astrojs/internal-helpers, @astrojs/lit, @astrojs/markdoc, @astrojs/markdown-remark, @astrojs/mdx, @astrojs/netlify, @astrojs/node, @astrojs/partytown, @astrojs/preact, @astrojs/prism, @astrojs/react, @astrojs/rss, @astrojs/sitemap, @astrojs/solid-js, @astrojs/svelte, @astrojs/tailwind, @astrojs/telemetry, @astrojs/underscore-redirects, @astrojs/upgrade, @astrojs/vercel, @astrojs/vue, @benchmark/timer, astro, create-astro
• Running build in 27 packages
• Remote caching enabled
::group::@astrojs/internal-helpers:build
cache miss, executing c34e3f9b14adcea6

> @astrojs/internal-helpers@0.2.1 build /home/runner/work/astro/astro/packages/internal-helpers
> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json

::endgroup::
::group::@astrojs/prism:build
cache miss, executing 5e1454343604b0d7

> @astrojs/prism@3.0.0 build /home/runner/work/astro/astro/packages/astro-prism
> astro-scripts build "src/**/*.ts" && tsc -p ./tsconfig.json

::endgroup::
::group::@astrojs/upgrade:build
cache miss, executing c34ad856d466d58f

> @astrojs/upgrade@0.2.3 build /home/runner/work/astro/astro/packages/upgrade
> astro-scripts build "src/index.ts" --bundle && tsc

::endgroup::
::group::@astrojs/telemetry:build
cache miss, executing 86667968c3c4e10e

> @astrojs/telemetry@3.0.4 build /home/runner/work/astro/astro/packages/telemetry
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::create-astro:build
cache miss, executing 982b14893db449f7

> create-astro@0.0.0-db-batch-20240307184301 build /home/runner/work/astro/astro/packages/create-astro
> astro-scripts build "src/index.ts" --bundle && tsc

::endgroup::
::group::@astrojs/markdown-remark:build
cache miss, executing 6c4342cbec102ab4

> @astrojs/markdown-remark@4.2.1 build /home/runner/work/astro/astro/packages/markdown/remark
> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json

::endgroup::
::group::astro:build
cache miss, executing bbf1d2c6b4ede410

> astro@0.0.0-db-batch-20240307184301 build /home/runner/work/astro/astro/packages/astro
> pnpm run prebuild && astro-scripts build "src/**/*.{ts,js}" && tsc && pnpm run postbuild


> astro@0.0.0-db-batch-20240307184301 prebuild /home/runner/work/astro/astro/packages/astro
> astro-scripts prebuild --to-string "src/runtime/server/astro-island.ts" "src/runtime/client/{idle,load,media,only,visible}.ts"


> astro@0.0.0-db-batch-20240307184301 postbuild /home/runner/work/astro/astro/packages/astro
> astro-scripts copy "src/**/*.astro" && astro-scripts copy "src/**/*.wasm"

::endgroup::
::group::@astrojs/lit:build
cache miss, executing c2f87429ce352ac6

> @astrojs/lit@4.0.1 build /home/runner/work/astro/astro/packages/integrations/lit
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/alpinejs:build
cache miss, executing db4a48d465b80a49

> @astrojs/alpinejs@0.4.0 build /home/runner/work/astro/astro/packages/integrations/alpinejs
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/partytown:build
cache miss, executing b5ae7ad744c75e9a

> @astrojs/partytown@2.0.4 build /home/runner/work/astro/astro/packages/integrations/partytown
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@benchmark/timer:build
cache miss, executing 3a38d5e5baf65658

> @benchmark/timer@0.0.0 build /home/runner/work/astro/astro/benchmark/packages/timer
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/tailwind:build
cache miss, executing e523cebc74982a9d

> @astrojs/tailwind@5.1.0 build /home/runner/work/astro/astro/packages/integrations/tailwind
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/solid-js:build
cache miss, executing 5a523db3876c0c6b

> @astrojs/solid-js@4.0.1 build /home/runner/work/astro/astro/packages/integrations/solid
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/markdoc:build
cache miss, executing e4933939415a79e8

> @astrojs/markdoc@0.9.1 build /home/runner/work/astro/astro/packages/integrations/markdoc
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/preact:build
cache miss, executing eb762f6885be6a75

> @astrojs/preact@3.1.1 build /home/runner/work/astro/astro/packages/integrations/preact
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/svelte:build
cache miss, executing 980e497e8f1a565d

> @astrojs/svelte@5.2.0 build /home/runner/work/astro/astro/packages/integrations/svelte
> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc

::endgroup::
::group::@astrojs/db:build
cache miss, executing cddc3bbb4988d318

> @astrojs/db@0.0.0-db-batch-20240307184301 build /home/runner/work/astro/astro/packages/db
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/rss:build
cache miss, executing f3827abe43869350

> @astrojs/rss@4.0.5 build /home/runner/work/astro/astro/packages/astro-rss
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/react:build
cache miss, executing 5a3afc35519a2749

> @astrojs/react@3.0.10 build /home/runner/work/astro/astro/packages/integrations/react
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/underscore-redirects:build
cache miss, executing 69f0a5b4e895baae

> @astrojs/underscore-redirects@0.3.3 build /home/runner/work/astro/astro/packages/underscore-redirects
> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json

::endgroup::
::group::@astrojs/node:build
cache miss, executing def5160a5397b5dc

> @astrojs/node@8.2.3 build /home/runner/work/astro/astro/packages/integrations/node
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/mdx:build
cache miss, executing 07d48cd23722dd12

> @astrojs/mdx@2.1.1 build /home/runner/work/astro/astro/packages/integrations/mdx
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/vercel:build
cache miss, executing 66b480be520d14db

> @astrojs/vercel@7.3.5 build /home/runner/work/astro/astro/packages/integrations/vercel
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/vue:build
cache miss, executing 3038eb5bb3952f41

> @astrojs/vue@4.0.8 build /home/runner/work/astro/astro/packages/integrations/vue
> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc

::endgroup::
::group::@astrojs/sitemap:build
cache miss, executing 9f8b13e45e670f9b

> @astrojs/sitemap@3.1.1 build /home/runner/work/astro/astro/packages/integrations/sitemap
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::

 Tasks:    25 successful, 25 total
Cached:    0 cached, 25 total
  Time:    50.884s 

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not familiar with the code, so hard to review, but left one question.

In the PR description docs says “N/A” but if this is something we support, wouldn’t we need to document it?

packages/db/package.json Outdated Show resolved Hide resolved
@bholmesdev
Copy link
Contributor Author

@delucis re-documentation: I'm using Sarah's suggestion to outsource to the Drizzle docs as much as possible to avoid explaining all of their features. There is an argument to document db.batch() as a best practice for seeding though. There were mixed thoughts on recommending batch early, so I'll raise in the docs discussion thread.

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using Sarah's suggestion to outsource to the Drizzle docs

Ah, OK — assumed as we were adding support, there might be something Astro-specific to the API separate from Drizzle’s batch API. If that’s not the case, then all’s good!

Approving from a place of ignorance — a batch made in heaven 🙌

@bholmesdev bholmesdev merged commit 988aad6 into main Mar 7, 2024
13 checks passed
@bholmesdev bholmesdev deleted the feat/db-batch branch March 7, 2024 19:49
@astrobot-houston astrobot-houston mentioned this pull request Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants