question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Created & updated time stamps

See original GitHub issue

Is 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:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
IEvangelistcommented, Aug 26, 2021

I like the idea of a readonly member that reads, parses and represents the LatestUpdatedUtc. 👍🏼

0reactions
mumby0168commented, Dec 22, 2021

Thanks, @robertbennett1998 great work for this on PR #150

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found