Bun now has MariaDB, PostgreSQL and SQLite baked in

With its additional database support Bun is looking even better for creating APIs…

Adding records:

const users = [
  { name: "Alice", email: "alice@example.com" },
  { name: "Bob", email: "bob@example.com" },
  { name: "Charlie", email: "charlie@example.com" },
];

await sql`INSERT INTO users ${sql(users)}`;

Updating a record:

await sql`UPDATE users SET ${sql(user)} WHERE id = ${user.id}`;

Getting records:

await sql`SELECT * FROM users WHERE id IN ${sql([1, 2, 3])}`;

For someone who creates a fair few single page apps with a JSON-RPC back-end this looks a bit of a dream :wink:

4 Likes