Skip to content

Comments

doc: add using keyword examples to sqlite#59765

Open
araujogui wants to merge 3 commits intonodejs:mainfrom
araujogui:doc/sqlite-explicit
Open

doc: add using keyword examples to sqlite#59765
araujogui wants to merge 3 commits intonodejs:mainfrom
araujogui:doc/sqlite-explicit

Conversation

@araujogui
Copy link
Member

Add using keyword usage examples to sqlite docs.

Shows how DatabaseSync can be scoped with using so the connection is
closed automatically. Makes Symbol.dispose usage clearer and easier to
discover.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/sqlite

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. sqlite Issues and PRs related to the SQLite subsystem. labels Sep 5, 2025
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
@geeksilva97
Copy link
Contributor

Is there a reason why all the examples should be like that? I wonder if we can have a variety of them.

@araujogui
Copy link
Member Author

Is there a reason why all the examples should be like that? I wonder if we can have a variety of them.

Since this is a new feature, I believe we should introduce it by demonstrating its use and reinforcing best practices to improve the ecosystem

@geeksilva97
Copy link
Contributor

geeksilva97 commented Sep 5, 2025

Is there a reason why all the examples should be like that? I wonder if we can have a variety of them.

Since this is a new feature, I believe we should introduce it by demonstrating its use and reinforcing best practices to improve the ecosystem

It's definitely something we want to have in the docs. I don't see a reason for doing that for all examples, though.

@louwers
Copy link
Contributor

louwers commented Sep 5, 2025

I agree that it should not be used in all examples, especially considering:

  1. It is not clear what the scope of the database handle is. If it is top-level scope, using will not do anything.
  2. It makes it seem like you need explicit resource management. You don't (correct me if I am wrong). The database will be closed when it is garbage collected.

@geeksilva97
Copy link
Contributor

geeksilva97 commented Sep 5, 2025

What if we have one example in this section?

@Renegade334
Copy link
Member

Worth pointing out that any use of using in the docs will need dont-land labels for pre-v24.x, and will diverge the documentation in the different version branches, which can be problematic for landing future PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. sqlite Issues and PRs related to the SQLite subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants