mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 09:51:39 +00:00
22 lines
566 B
Templ
22 lines
566 B
Templ
package scripts
|
|||
|
|
|
||
|
|
templ InitializeDatabase() {
|
||
|
|
<script type="module">
|
||
|
|
// Import Dexie
|
||
|
|
import { Dexie } from 'https://unpkg.com/dexie/dist/modern/dexie.mjs';
|
||
|
|
|
||
|
|
// Create a new Dexie database
|
||
|
|
const db = new Dexie('myDatabase');
|
||
|
|
|
||
|
|
// Define the schema for the database
|
||
|
|
db.version(1).stores({
|
||
|
|
users: '++id, name, age',
|
||
|
|
posts: '++id, title, content, authorId',
|
||
|
|
comments: '++id, content, postId, authorId',
|
||
|
|
});
|
||
|
|
|
||
|
|
// Export the database instance
|
||
|
|
export default db;
|
||
|
|
</script>
|
||
|
|
}
|