Dexie.exists()
Syntax
Return Value
Promise<boolean>
Description
Checks whether a database with the given name exists or not. Returns a Promise that resolves with true or false.
IMPORTANT NOTICE
You normally won't need this method! Dexie will automatically detect if database creation or upgrade is needed. The following checks are made withing db.open()
:
If database does not exists, Dexie will create it automatically.
If database exists but on a previous version, Dexie will upgrade it for you.
If database exists on the declared version, Dexie will just open it for you.
So, DON'T do stuff like:
It's simply NOT needed. Instead, just do:
...and it will create the db when needed but just open it if not needing to create it.
Sample
As stated out in the 'IMPORTANT NOTICE' above, this method is never needed in normal scenarios. But if you of some reason just want to find out if a database exists without actually using it, you could do something like the following: