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
/
Copy pathtest-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()