Spaces:
Running
Running
Commit
·
0c378b9
1
Parent(s):
4d2efbd
Initial setups refine for ingestion_js #9 (upd mongo)
Browse files- ingestion_js/lib/mongo.ts +25 -2
ingestion_js/lib/mongo.ts
CHANGED
|
@@ -99,6 +99,29 @@ export async function deleteFileData(user_id: string, project_id: string, filena
|
|
| 99 |
|
| 100 |
export async function ensureIndexes() {
|
| 101 |
const { db } = await getMongo()
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
}
|
|
|
|
| 99 |
|
| 100 |
export async function ensureIndexes() {
|
| 101 |
const { db } = await getMongo()
|
| 102 |
+
console.log('[MONGO_DEBUG] Ensuring indexes...')
|
| 103 |
+
|
| 104 |
+
try {
|
| 105 |
+
await db.collection('chunks').createIndex({ user_id: 1, project_id: 1, filename: 1 }, { unique: false })
|
| 106 |
+
console.log('[MONGO_DEBUG] Chunks index created/verified')
|
| 107 |
+
} catch (error: any) {
|
| 108 |
+
if (error.code === 86) {
|
| 109 |
+
console.log('[MONGO_DEBUG] Chunks index already exists with different options, skipping')
|
| 110 |
+
} else {
|
| 111 |
+
throw error
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
try {
|
| 116 |
+
await db.collection('files').createIndex({ user_id: 1, project_id: 1, filename: 1 }, { unique: false })
|
| 117 |
+
console.log('[MONGO_DEBUG] Files index created/verified')
|
| 118 |
+
} catch (error: any) {
|
| 119 |
+
if (error.code === 86) {
|
| 120 |
+
console.log('[MONGO_DEBUG] Files index already exists with different options, skipping')
|
| 121 |
+
} else {
|
| 122 |
+
throw error
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
console.log('[MONGO_DEBUG] Indexes ensured')
|
| 127 |
}
|