add EventsSelect component

This commit is contained in:
Gabriel Pastori
2024-01-07 17:19:01 -03:00
parent ba720aea82
commit 2f6c896f0a
10 changed files with 241 additions and 98 deletions

View File

@@ -34,14 +34,22 @@ module.exports = async (instanceName, options, progressBars, conn, connInstance)
const collectionName = file.key || instanceName
const collection = (!file.secondaryConnection ? conn : connInstance).collection(collectionName)
const data = JSON.parse(fs.readFileSync(file.path, 'utf8'))
var data;
try {
data = JSON.parse(fs.readFileSync(file.path, 'utf8'))
} catch (err) {
continue;
}
if (Array.isArray(data)) continue
data._id = file.path.split('\\').pop().split('.')[0]
await collection.findOneAndUpdate({ _id: data._id }, { $set: data }, { upsert: true })
progress.increment()
} catch (err) {
progress.stop()
throw { err, file }
} finally {
progress.increment()
}
}
}