Redis write-behind persists data as date string format on database, but I need the ISODate format

Hello everyone.

I have a chat application project developed in nodejs with mongoDB which implements Redis Gears, and the write-behind pattern. I set the schema using nodejs and use python rgsync’s RGJSONWriteBehind recipe.
Everything works fine as far as setting everything up goes, and successfully writing to the database.
However, I wanted to implement data expiration (MongoDB TTL Indexes) and for that, you MUST have a ISODate field (this means date strings do not work) .
Now here comes the problem, when you use the write-behind pattern, Redis gears writes to MongoDB as (correct me if I am wrong) JSON data which stringifies my createdAt date field into ‘2024-10-01T14:12:44.969Z’ and MongoDB won’t recognize as a valid date format for the data expiration (it should be ISODate(‘2024-10-01T14:12:44.969Z’).
This way, the data will not be deleted from the database after its expiration time which is the expected behavior.

I have tried different solutions, like:

Set a timestamp field with a Date value as the default, but for a reason I dont know, when using redis gears to write to the database, this field is ignored and nothing is passed to it so a find() query with mongoDB does not even return the timestamp field.
I have even dropped the database to make sure it got implemented and made sure to test write to MongoDB without redis gears. It got persisted correctly:

{
_id: ObjectId(‘66fc2901e0d9f9daba7d5dea’),
messageId: ‘25c05087-2a8c-4631-853a-9bb9d0d688b4’,
room: ‘JavaScript’,
username: ‘rubemarjr18’,
text: ‘hi’,
createdAt: ISODate(‘2024-10-01T16:53:21.007Z’),
timestamp: ISODate(‘2024-10-01T16:53:21.007Z’),
__v: 0
}

Setting a mongoose.pre(‘save’) hook to try and modify the the createdAt field before saving (did not work, nothing happened).

So I suppose I can not do anything from my schema definition to modify the data Redis writes to MongoDB.

Which comes to my question, any ideas on what I could do to get it to write my createdAt field as ISODate() so my data expiration can work.

I would appreciate any help.

Thank you for your time.