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.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log('try connect')
|
||||||
mongoDBConnect().then(async (client) => {
|
mongoDBConnect().then(async (client) => {
|
||||||
const db = await client.db(process.env.DB_NAME)
|
console.log('Connected to MongoDB')
|
||||||
const collection = await db.collection(process.env.COLLECTION_NAME)
|
try {
|
||||||
|
const db = await client.db(process.env.DB_NAME)
|
||||||
const answer = await collection[process.env.COMMAND](JSON.parse(process.env.ARGUMENT))
|
const collection = await db.collection(process.env.COLLECTION_NAME)
|
||||||
|
|
||||||
await client.close();
|
console.log('command', process.env.COMMAND)
|
||||||
return answer.ops?.[0] ?? answer
|
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)
|
.then(console.log)
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
|
Loading…
Reference in New Issue
Block a user