oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
71.81k stars 2.56k forks source link

Add support for `create: true` to Bun SQLite database imports #8202

Open TomasHubelbauer opened 5 months ago

TomasHubelbauer commented 5 months ago

What is the problem this feature would solve?

Would be able to use the SQLite database import while also wanting the create: true behavior the current Database constructor exposes.

What is the feature you are proposing to solve the problem?

import database from './db.sqlite' with { type: 'sqlite', create: true };
console.log(database.prepare(`SELECT sqlite_version()`).get());

What alternatives have you considered?

Not doing it, people can always use the Database constructor.

Electroid commented 5 months ago

This makes sense, though we would have to make it “true” as a string, due to how import attributes works.

infrahead commented 5 months ago

Yes please. Ideally should support any open flags supported by the Database constructor. E.g I'd also like readOnly.

and not sure if needs to be another issue, but expanding to these other options would be even better: https://github.com/oven-sh/bun/pull/8178#issuecomment-1892250152