Hi,
I am saving an object in the localstore where createdAt is made automatically by the db. I want to access the createdAt property of a particular object. It does not get retrieved with client.db.get(key). Can anyone help me figure out how to retrieve createdAt property from the localstore object?
In Freshdesk’s key-value storage (localstore), the createdAt property is automatically generated by the database and is not directly accessible. However, you can store the createdAt timestamp as part of the object itself to retrieve it later. Here’s an example of how you can achieve this:
When saving the object to the localstore, include the createdAt timestamp as a property within the object. For example:
const objectToSave = {
data: "Your object data",
createdAt: new Date().toISOString() // Include the timestamp
};
client.db.set(key, objectToSave);
When retrieving the object from the localstore using client.db.get(key), you can access the createdAt property within the retrieved object:
const retrievedObject = client.db.get(key);
if (retrievedObject) {
const createdAtTimestamp = retrievedObject.createdAt;
// Use the createdAt timestamp as needed
} else {
// Object not found
}