-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-test-data.mjs
More file actions
59 lines (51 loc) · 1.84 KB
/
add-test-data.mjs
File metadata and controls
59 lines (51 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Test script to add sample data to Firestore
import { initializeApp } from 'firebase/app';
import { getFirestore, collection, addDoc, Timestamp } from 'firebase/firestore';
const firebaseConfig = {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
async function addTestData() {
try {
// Add a test document with a fake user ID
const testDoc = {
userId: 'test-user-123', // We'll use this to test our queries
title: 'Test Movie',
type: 'movie',
status: 'want-to-watch',
genre: 'Action',
year: 2024,
rating: null,
notes: 'This is a test movie entry',
createdAt: Timestamp.now(),
updatedAt: Timestamp.now()
};
const docRef = await addDoc(collection(db, 'media-items'), testDoc);
console.log('✅ Test document added with ID:', docRef.id);
// Add another one for a different user
const testDoc2 = {
userId: 'different-user-456',
title: 'Another Test Movie',
type: 'movie',
status: 'watched',
genre: 'Comedy',
year: 2023,
rating: 8,
notes: 'This belongs to a different user',
createdAt: Timestamp.now(),
updatedAt: Timestamp.now()
};
const docRef2 = await addDoc(collection(db, 'media-items'), testDoc2);
console.log('✅ Second test document added with ID:', docRef2.id);
console.log('🎉 Test data added successfully!');
} catch (error) {
console.error('❌ Error adding test data:', error);
}
}
addTestData();