Spaces:
Sleeping
Sleeping
File size: 1,481 Bytes
14b0378 | 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 | import { initializeApp } from 'firebase/app';
import { getFirestore, collection, getDocs, query, orderBy, limit } from 'firebase/firestore';
const firebaseConfig = {
apiKey: "AIzaSyAH3jvbe0_QLzIuuv5kTMK8246HNvohvfE",
authDomain: "twistedbrody-9d163.firebaseapp.com",
projectId: "twistedbrody-9d163",
storageBucket: "twistedbrody-9d163.firebasestorage.app",
messagingSenderId: "733213514129",
appId: "1:733213514129:web:e9694684f5c3994ed06230",
measurementId: "G-N8TQ7MY42W"
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
async function check() {
console.log("Fetching mangas from DB...");
const q = query(collection(db, 'mangas'), orderBy('created_at', 'desc'), limit(3));
const snap = await getDocs(q);
if (snap.empty) {
console.log("NO MANGAS IN DB!");
} else {
snap.forEach(doc => {
console.log(`Manga ${doc.id}: ${doc.data().title}`);
console.log(JSON.stringify(doc.data(), null, 2));
});
}
console.log("\nFetching chapters...");
const q2 = query(collection(db, 'chapters'), orderBy('created_at', 'desc'), limit(3));
const snap2 = await getDocs(q2);
if (snap2.empty) {
console.log("NO CHAPTERS IN DB!");
} else {
snap2.forEach(doc => {
console.log(`Chapter ${doc.id}: ${doc.data().title}`);
console.log(JSON.stringify(doc.data(), null, 2));
});
}
}
check().catch(console.error).finally(() => process.exit(0));
|