-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43ff34a
commit ab5cb3c
Showing
4 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { UserDB } from './db'; | ||
import { predefinedUsers } from '../data/users'; | ||
|
||
export async function initializeDatabase() { | ||
try { | ||
// Check if test user exists | ||
const testUser = await UserDB.findByEmail('[email protected]'); | ||
|
||
if (!testUser) { | ||
// Initialize predefined users if they don't exist | ||
for (const user of predefinedUsers) { | ||
const existingUser = await UserDB.findByEmail(user.email); | ||
if (!existingUser) { | ||
await UserDB.create({ | ||
email: user.email, | ||
password: user.password, | ||
name: user.name | ||
}); | ||
} | ||
} | ||
} | ||
} catch (error) { | ||
console.error('Failed to initialize database:', error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters