Implement createdAt / updatedAt fields
complete
Alex Francoeur
complete
This has been delivered with more details in our changelog. Let us know what you think! https://xata.io/roadmap
Kostas Botsas
createdAt and updatedAt timestamps are now part of the record metadata under the nested fields xata.createdAt and xata.updatedAt.
const rec = await xata.db.test.getFirst();
console.log(rec.getMetadata());
{
"createdAt":"2023-05-22T14:28:43.884726Z"
"updatedAt":"2023-05-22T14:28:43.884726Z"
"version":0
}
We are currently working on exposing these values in the Web UI.
Kostas Botsas
in progress
We are currently working on adding createdAt and updatedAt timestamp metadata for all records.
Alex Francoeur
From Discord: https://discord.com/channels/996791218879086662/1084580138236264539/1084860672124403743
"Built in created/updated timestamps for all record"
Kostas Botsas
Regarding createdAt: The datetime column supports "now" as a default value option (see datetime in https://xata.io/docs/concepts/data-model).
In the Web UI you can select the default value "now" when creating a new column of type "Date".
You can also set "default value now" when creating a new column using the CLI with xata schema edit:
{
"name": "createdAt",
"type": "datetime"
"notNull": true,
"defaultValue": "now",
}
updatedAt still needs to be handled by the client, there is no built in feature in Xata for it yet.