The below payload has 4 array inside data. One of these is refresh_tokens
and in it one of the properties is last_used
which has a datetime in it. I want to use this datatime to know if 3 days has past from that date and then delete the segment of array with last_used
beyond 3 days.
{
"version": 1,
"key": "auth",
"data": {
"users": [
{
"id": 456,
"is_active": true,
"system_generated": false
}
],
"groups": [
{
"id": "admin",
"name": "deff12"
}
],
"credentials": [
{
"id": 45,
"auth": null,
"data": {
"username": "user"
}
}
],
"refresh_tokens": [
{
"user_id": 122,
"last_used_at": null,
"version": null
},
{
"user_id": 123,
"last_used_at": "2021-11-25T00:54:31.341554+00:00",
"version": null
},
{
"user_id": 134,
"last_used_at": "2021-11-21T01:19:56.970797+00:00",
"version": "2021.11.4"
}
]
}
}
For example in the above payload, the 3 segment in refresh_tokens
has the last_used
datetime as 2021-11-21T01:19:56.970797+00:00
. More than 3 days has passed since it and so deleting it the final payload should look like below.
{
"version": 1,
"key": "auth",
"data": {
"users": [
{
"id": 456,
"is_active": true,
"system_generated": false
}
],
"groups": [
{
"id": "admin",
"name": "deff12"
}
],
"credentials": [
{
"id": 45,
"auth": null,
"data": {
"username": "user"
}
}
],
"refresh_tokens": [
{
"user_id": 122,
"last_used_at": null,
"version": null
},
{
"user_id": 123,
"last_used_at": "2021-11-25T00:54:31.341554+00:00",
"version": null
}
]
}
}