log command
This commit is contained in:
parent
69f48b83c4
commit
14035266e5
23
index.js
23
index.js
@ -28,14 +28,23 @@ const mongoDBConnect = async () => {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
console.log('try connect')
|
||||
mongoDBConnect().then(async (client) => {
|
||||
const db = await client.db(process.env.DB_NAME)
|
||||
const collection = await db.collection(process.env.COLLECTION_NAME)
|
||||
|
||||
const answer = await collection[process.env.COMMAND](JSON.parse(process.env.ARGUMENT))
|
||||
|
||||
await client.close();
|
||||
return answer.ops?.[0] ?? answer
|
||||
console.log('Connected to MongoDB')
|
||||
try {
|
||||
const db = await client.db(process.env.DB_NAME)
|
||||
const collection = await db.collection(process.env.COLLECTION_NAME)
|
||||
|
||||
console.log('command', process.env.COMMAND)
|
||||
console.log('argument', process.env.ARGUMENT, process.env.ARGUMENT.replace("ISODate()", `${new Date().toISOString()}`))
|
||||
|
||||
const answer = await collection[process.env.COMMAND](JSON.parse(process.env.ARGUMENT.replaceAll("ISODate()", `${new Date().toISOString()}`)))
|
||||
|
||||
await client.close();
|
||||
return answer.ops?.[0] ?? answer
|
||||
} catch (error) {
|
||||
await client.close();
|
||||
}
|
||||
})
|
||||
.then(console.log)
|
||||
.catch(console.error)
|
||||
|
Loading…
Reference in New Issue
Block a user