Initial commit
All checks were successful
Docker Build and Publish / build-and-push (push) Successful in 2m17s
All checks were successful
Docker Build and Publish / build-and-push (push) Successful in 2m17s
This commit is contained in:
32
frontend/seed.js
Normal file
32
frontend/seed.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import PocketBase from 'pocketbase';
|
||||
|
||||
const pb = new PocketBase('http://127.0.0.1:8090');
|
||||
|
||||
async function seed() {
|
||||
try {
|
||||
// Check if user exists
|
||||
try {
|
||||
await pb.collection('users').authWithPassword('test@example.com', 'password123');
|
||||
console.log('User already exists');
|
||||
return;
|
||||
} catch (e) {
|
||||
// User likely doesn't exist
|
||||
}
|
||||
|
||||
const data = {
|
||||
"username": "testuser",
|
||||
"email": "test@example.com",
|
||||
"emailVisibility": true,
|
||||
"password": "password123",
|
||||
"passwordConfirm": "password123",
|
||||
"name": "Test User"
|
||||
};
|
||||
|
||||
const record = await pb.collection('users').create(data);
|
||||
console.log('User created:', record.id);
|
||||
} catch (error) {
|
||||
console.error('Error seeding user:', error);
|
||||
}
|
||||
}
|
||||
|
||||
seed();
|
||||
Reference in New Issue
Block a user