Closed Cyrof closed 2 months ago
Date is generated here is a date object
const roomSess : roomSession = {
room_pin: pin,
room_sess: sessionId,
createdAt: new Date(),
}
but when parse to the api to be handle to save to mongodb here
const response = await fetch('/api/saveData', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(roomSess),
});
Because of JSON.stringify(roomSess)
, the data type of the createdAt
value becomes a String instead of a Date. Therefore when api saves the data into mongodb, the value of createdAt
is a String and thereafter is not recognised by the TTL.
Issue resolve in this commit ee2165fd4e06923152dbba431bb624aef7849897.
Added data validation to check for createdAt
datatype
if (typeof body.createdAt === "string"){
body.createdAt = new Date(body.createdAt);
}
Database Time-To-Live (TTL) Not working
The database TTL for documents is not working. Fix is required ASAP.
More Information Required