Created & updated time stamps
See original GitHub issueIs your feature request related to a problem? Please describe.
n/a
Describe the solution you’d like
- When a document is created mark the current time as
DateTime.UtcNow
- When a document is modified mark the last updated time as
DateTime.UtcNow
Describe alternatives you’ve considered This can be controlled manually by a user but it may be a nice addition for this library to handle.
Additional context
This is what the Item
class could look like
public abstract class Item : IItem
{
[JsonProperty("id")]
public string Id { get; set; } = Guid.NewGuid().ToString();
[JsonProperty("type")]
public string Type { get; set; }
string IItem.PartitionKey => GetPartitionKeyValue();
public Item() => Type = GetType().Name;
protected virtual string GetPartitionKeyValue() => Id;
[JsonProperty("createdUtc")]
public DateTime CreatedUtc { get; internal set; }
[JsonProperty("lastUpdatedUtc")]
public DateTime LastUpdatedUtc { get; internal set; }
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Having both a Created and Last Updated timestamp ...
One TIMESTAMP column in a table can have the current timestamp as the default value for initializing the column, as the auto-update value,...
Read more >How to add “created” and “updated” timestamps without triggers
You have a table that you want to add "created" and "updated" timestamp columns to, but you can't update the application code to...
Read more >11.2.5 Automatic Initialization and Updating for ...
TIMESTAMP and DATETIME columns can be automatically initialized and updated to the current date and time (that is, the current timestamp).
Read more >Auto Updating Created, Updated and Deleted Timestamps In ...
In any database schema, it's extremely common to have the fields “DateCreated, DateUpdated and DateDeleted” on almost every entity.
Read more >Timestamps
createdAt : a date representing when this document was created; updatedAt : a date representing when this document was last updated. Mongoose will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I like the idea of a
readonly
member that reads, parses and represents theLatestUpdatedUtc
. 👍🏼Thanks, @robertbennett1998 great work for this on PR #150