forked from userbot000/otzaria-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-library-api.js
More file actions
50 lines (39 loc) · 1.58 KB
/
test-library-api.js
File metadata and controls
50 lines (39 loc) · 1.58 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
// סקריפט בדיקה מהיר לראות מה יש ב-MongoDB
import { MongoClient } from 'mongodb'
import dotenv from 'dotenv'
dotenv.config({ path: '.env.local' })
const uri = process.env.DATABASE_URL
async function testLibraryAPI() {
const client = new MongoClient(uri)
try {
await client.connect()
const db = client.db('otzaria')
const collection = db.collection('files')
console.log('🔍 מחפש קבצי pages...')
// מצא את כל הקבצים שמתחילים ב-data/pages/
const files = await collection
.find({ path: { $regex: '^data/pages/' } })
.toArray()
console.log(`\n📦 נמצאו ${files.length} קבצים:\n`)
for (const file of files) {
console.log(`📄 ${file.path}`)
if (Array.isArray(file.data)) {
const totalPages = file.data.length
const completed = file.data.filter(p => p.status === 'completed').length
console.log(` ├─ סה"כ עמודים: ${totalPages}`)
console.log(` ├─ הושלמו: ${completed}`)
console.log(` └─ תמונה ראשונה: ${file.data[0]?.thumbnail || 'אין'}`)
} else {
console.log(` └─ ⚠️ הנתונים לא במבנה מערך!`)
console.log(` └─ סוג הנתונים: ${typeof file.data}`)
console.log(` └─ מבנה: ${JSON.stringify(file.data).substring(0, 200)}...`)
}
console.log('')
}
} catch (error) {
console.error('❌ שגיאה:', error)
} finally {
await client.close()
}
}
testLibraryAPI()