Skip to content

Best practices NodeJS

Timezone

The node js uses the local time settings. In local development it uses the settings from your Mac (Berlin) and on development it uses the server settings (often Londen)To get same result as on development, update Mac preferences and restart all applications. https://dev.to/kelkes/running-node-in-utc-instead-of-local-timezone-3gki > this doesn’t work on Mac

Only store UTC format in DateTime. UTC is not a format and refers to “Coordinated Universal Time” This is a fixed clock at the prime meridian, equivalent to GMT for all practical purposes. It does not change for “daylight savings time” or “summer time”, and it is where we place the zero when talking about offsets of other time zones.
The ISO8601 standard defines several formats, but the one most commonly used is also defined in RFC3339 .When you have a string value that includes a Z or +00:00 at the end, you know that it represents time at UTC, and can be stored in a DateTime.
If you have some other offset, such as +01:00 or -04:00, then you should be storing these in a DateTimeOffset object instead. If you try to store it in a DateTime, then you have to choose whether you are going to ignore the offset, or apply it and store the time as UTC.

Transactions

Do not use try /catch in a transaction unless you throw the error. Everything you did inside the same transaction is visible to later commands inside the same transaction. Just not to other transactions until committed. This is true for all isolation levels except Read uncommitted where “dirty reads” are possible

Published inUncategorized

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *