pglite icon indicating copy to clipboard operation
pglite copied to clipboard

Add static method to delete databases

Open samwillis opened this issue 1 year ago • 2 comments

With v0.2 we will have this api as an options for specifying a VFS:

import { IdbFs } from "@electric-sql/pglite";
const pg = new PGlite({
  fs: new IdbFs("my-database")
})

We should add a delete static method to the VFS interface that deletes the database from the underlying storage:

import { IdbFs } from "@electric-sql/pglite";

IdbFs.delete('my-database')

samwillis avatar Aug 02 '24 15:08 samwillis

Would also like a method to clear the database. For unit testing re-initializing pglite every test is too slow. I am using a query to drop all tables in my afterEach but would prefer a more deterministic method.

codewithcheese avatar Aug 13 '24 12:08 codewithcheese

Would also like a method to clear the database. For unit testing re-initializing pglite every test is too slow. I am using a query to drop all tables in my afterEach but would prefer a more deterministic method.

@codewithcheese Probably a good option would be DROP DATABASE ... instead of the tables. But I don't think there's a way to switch databases in pglite atm.

tdrz avatar Apr 21 '25 15:04 tdrz