Skip to content

Instantly share code, notes, and snippets.

@bsitruk
Last active February 7, 2022 10:40
Show Gist options
  • Save bsitruk/11db7db11253fb44cbaf176ebcf690c5 to your computer and use it in GitHub Desktop.
Save bsitruk/11db7db11253fb44cbaf176ebcf690c5 to your computer and use it in GitHub Desktop.
function getCurrentDateP(mongoConnection) {
const query = { _id: 1 };
const update = { $currentDate: { updated_at: true } };
const queryOptions = { upsert: true, returnOriginal: false };
return mongoConnection
.collection('current_date')
.findOneAndUpdate(query, update, queryOptions)
.then(mongoResult => mongoResult.value.updated_at)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment