All checks were successful
Docker Build and Publish / build-and-push (push) Successful in 34s
33 lines
910 B
JavaScript
33 lines
910 B
JavaScript
import PocketBase from 'pocketbase';
|
|
|
|
const pb = new PocketBase(process.env.POCKETBASE_URL || '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();
|