I need to change the value of 'payments._id' to a timestamp. In MongoDB, the 'payments._id' object is automatically generated when inserting a document into the collection.
onMounted(async () => {
const res = await axios.get("http://127.0.0.1:49146/server/po_payment");
payments.value = res.data;
I'm attempting to convert the _id field of a document in a MongoDB collection to a timestamp. I tried using getTimestamp(), but it didn't work. While it seems to work in the MongoDB shell, I'm uncertain if it's only usable there. I've looked for solutions online, but I still haven't figured out how to achieve this. Do you have any suggestions?
onMounted(async () => {
const res = await axios.get("http://127.0.0.1:49146/server/po_payment");
payments.value = res.data;
payments.value.forEach(payment => {
payment.timestamp = new ObjectId(payment._id).getTimestamp();
});