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();
