Skip to content

Add guidance on how to use LibSQL with Astro DB#8955

Merged
sarah11918 merged 13 commits into4.15.0from
fryuni/db-with-libsql
Aug 28, 2024
Merged

Add guidance on how to use LibSQL with Astro DB#8955
sarah11918 merged 13 commits into4.15.0from
fryuni/db-with-libsql

Conversation

@Fryuni
Copy link
Copy Markdown
Member

@Fryuni Fryuni commented Jul 30, 2024

Description

  • Updates the Astro DB guide to include using LibSQL as the remote database.

Related issues & labels (optional)

@Fryuni Fryuni added the minor-release For the next minor release; in the milestone, "merge queue" = approved for merging on release day. label Jul 30, 2024
@Fryuni Fryuni requested a review from sarah11918 July 30, 2024 22:11
@Fryuni Fryuni self-assigned this Jul 30, 2024
@netlify
Copy link
Copy Markdown

netlify bot commented Jul 30, 2024

Deploy Preview for astro-docs-2 ready!

Name Link
🔨 Latest commit 9d7956d
🔍 Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/66ce475a3e1af60008254eb1
😎 Deploy Preview https://deploy-preview-8955--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@astrobot-houston
Copy link
Copy Markdown
Contributor

astrobot-houston commented Jul 30, 2024

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

Locale File Note
en guides/astro-db.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@sarah11918 sarah11918 added add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) and removed minor-release For the next minor release; in the milestone, "merge queue" = approved for merging on release day. labels Jul 30, 2024
- `ASTRO_DB_REMOTE_URL`: the connection URL to your LibSQL server
- `ASTRO_DB_APP_TOKEN`: the auth token to your LibSQL server

The environment variables have to be set during `astro build`, `astro db push --remote` and during runtime if your project use Astro DB on SSR pages.
Copy link
Copy Markdown
Member

@sarah11918 sarah11918 Aug 23, 2024

Choose a reason for hiding this comment

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

Can we explain or give an example of what someone needs to do to make sure these are set at the correct time? It's one thing to say they "have to be set during..", but it's helpful to show what they will need to do to make that happen. If simply setting the variables were enough, then this sentence wouldn't be necessary, right? So what else do they have to make sure they do?

ooops, this ended up as a plain comment, not review comment! I'm doing a review now, and the rest will come in one review batch!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Setting the environment variables is enough, but they have to do it in all places being used. So, for example, when deploying to Vercel you need the environment variable set locally when you run astro db push --remote to apply the schemas and on Vercel to connect to the DB.

Using Studio, the token only needs to be set on Vercel since the local run of astro db push --remote will use the user token.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So, would this be added to the command as a flag when run? Or just added in the appropriate places (one and done, like in a .env file or in a dashboard somewhere? I think this is what I'm getting at.

"Set when you run" could mean "pre-set, and available somewhere" or something you need to provide each time.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I made the examples show the .env file so people put it there. There is multiple ways to do it along with security considerations, but that will depend on how their project and their connection to LibSQL is structured. I don't think there is much point going into details on Astro Docs vs following the docs of the hosting they are using

Copy link
Copy Markdown
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Thanks @Fryuni , this is looking great! I can spot a few areas where I'd like to see more examples or have more descriptive help than "use", but this is pretty close to where I think it will end up! 🙌


The environment variables have to be set during `astro build`, `astro db push --remote` and during runtime if your project use Astro DB on SSR pages.

Details of the LibSQL connection can be configured using the connection URL.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Details of the LibSQL connection can be configured using the connection URL.
Details of the LibSQL connection (e.g. host, encryption key, sync interval) can be configured as query parameters in the remote connection URL.
For example, to ...
```
`ASTRO_DB_REMOTE_URL`:
```

My earlier comment holds here too. "using the connection URL" is not as helpful as spelling out specifically "as query parameters".

Can we have one actually, complete full example here showing the broader context to set people up for the following sections all being understood as additional query parameters? Pick the most common situation you can think of. There's been a lot of "you can set" below without seeing what that looks like.

@sarah11918 sarah11918 added this to the 4.15 milestone Aug 26, 2024
@sarah11918 sarah11918 added the minor-release For the next minor release; in the milestone, "merge queue" = approved for merging on release day. label Aug 26, 2024
Copy link
Copy Markdown
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

This looks great, @Fryuni ! Just a tiny bit of light editing on the top.

See what you think re: my comment about the commands, and at some point, I do wonder whether some of this belongs on the @astrojs/db integration reference page? (like the sync stuff?) and we just link to it from here? But I think this is fine for now, unless you see a way you'd prefer to offload some documentation to the other page.

Fryuni and others added 3 commits August 27, 2024 10:58
[skip ci]

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
[skip ci]

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
@sarah11918
Copy link
Copy Markdown
Member

Thanks @Fryuni ! Literally two tiny nits to get just right grammatically, and we're done! This is amazing, thank you!

Copy link
Copy Markdown
Member

@yanthomasdev yanthomasdev left a comment

Choose a reason for hiding this comment

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

Amazing work @Fryuni, I have a few suggestions. After applying those, LGTM!

Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
Copy link
Copy Markdown
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

We did it! 🥳 This is gonna be so popular, @Fryuni . Can't wait!

@sarah11918 sarah11918 added the Merge Queue Approved and ready to be merged (wait for feature release if also labelled M-O-R)! label Aug 27, 2024
@sarah11918 sarah11918 changed the base branch from main to 4.15.0 August 27, 2024 21:41
Copy link
Copy Markdown
Contributor

@lorenzolewis lorenzolewis left a comment

Choose a reason for hiding this comment

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

Optional nit

Co-authored-by: Lorenzo Lewis <lorenzo_lewis@icloud.com>

<p><Since pkg="@astrojs/db" v="0.14.0" /></p>

Astro DB can connect to any LibSQL server from any platform that exposes the Hrana protocol of the server, or can be self-hosted.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Astro DB can connect to any LibSQL server from any platform that exposes the Hrana protocol of the server, or can be self-hosted.
Astro DB can connect to any libSQL server from any platform that exposes the libSQL remote protocol of the server, or can be self-hosted.

We're moving away from calling it "Hrana", so not using it here would be a huge help 🫶

Copy link
Copy Markdown
Contributor

@lorenzolewis lorenzolewis Aug 28, 2024

Choose a reason for hiding this comment

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

As a reader, this also makes it a lot easier to understand what it is in this context.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The name everywhere I see is LibSQL with capital L, is that changing too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I looked again, and there seems to be a mix. I'll normalize our references to be libSQL but as a heads up @notrab , on Turso docs and the repos the links and titles are mostly using "LibSQL" while the content on the pages are using "libSQL".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good spot! I’ll make sure our docs are updated to reflect our new messaging, and additional pages on our site/GitHub repos.

@sarah11918
Copy link
Copy Markdown
Member

Thanks for jumping in here @notrab ! I'm glad this was caught in lots of time (a day... but for docs that's an eternity 😂 ) Will be released tomorrow! 🙌

Copy link
Copy Markdown
Member

@yanthomasdev yanthomasdev left a comment

Choose a reason for hiding this comment

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

LGTM!

@sarah11918
Copy link
Copy Markdown
Member

!coauthor

@github-actions
Copy link
Copy Markdown

Co-authored-by: Houston (Bot) <108291165+astrobot-houston@users.noreply.github.com>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Jamie Barton <jamie@notrab.dev>
Co-authored-by: Lorenzo Lewis <15347255+lorenzolewis@users.noreply.github.com>
Co-authored-by: Armand Philippot <59021693+ArmandPhilippot@users.noreply.github.com>
Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>

@sarah11918 sarah11918 merged commit 967b692 into 4.15.0 Aug 28, 2024
@sarah11918 sarah11918 deleted the fryuni/db-with-libsql branch August 28, 2024 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. Merge Queue Approved and ready to be merged (wait for feature release if also labelled M-O-R)! merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) minor-release For the next minor release; in the milestone, "merge queue" = approved for merging on release day.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants