Coder Social home page Coder Social logo

Timestamp about cuid HOT 6 CLOSED

paralleldrive avatar paralleldrive commented on June 20, 2024
Timestamp

from cuid.

Comments (6)

ericelliott avatar ericelliott commented on June 20, 2024

Yes, but I don't recommend it. You should create a separate timestamp instead.

See https://github.com/ericelliott/cuid#broken-down

and from the same README...

"The cuid specification should not be considered an API contract. Code that relies on the groupings as laid out here should be considered brittle and not be used in production."

from cuid.

 avatar commented on June 20, 2024

Thanks.

On Fri, Oct 10, 2014 at 9:00 PM, Eric Elliott [email protected]
wrote:

Yes, but I don't recommend it. You should create a separate timestamp
instead.

See https://github.com/ericelliott/cuid#broken-down

and from the same README...

"The cuid specification should not be considered an API contract. Code
that relies on the groupings as laid out here should be considered brittle
and not be used in production."


Reply to this email directly or view it on GitHub
#13 (comment).

Felipe Lorenzo VI

from cuid.

Cicko avatar Cicko commented on June 20, 2024

@ericelliott How can I find the algorithm to get the date from the cuid?

From what I see from the README it says that the first 8 characters after the letter 'c' is the timestamp, but how can I convert it to an actual date?

And why you don't recommend it?

Thanks in advance

from cuid.

ericelliott avatar ericelliott commented on June 20, 2024

As explained above, and in the documentation, you don't. If you need to know the time something was created, record a separate timestamp. Ids should only be used as ids, and the cuid spec was not designed for data extraction. Groupings do not have guaranteed lengths.

from cuid.

ericelliott avatar ericelliott commented on June 20, 2024

The security risk associated with extracting metadata from ids is the reason CUID is deprecated and we now prefer CUID2.

from cuid.

Cicko avatar Cicko commented on June 20, 2024

@ericelliott Thank you for your answer.

I asked because in our project we just added a field createdAt in our PostgresSQL recently and we set a default value of '1999-12-31 23:59:59.000' so all older tuples in the DB have this value which is unrealistic and I thought by running another migration and decode the id (which is a cuid) could at least populate a correct createdAt value.

from cuid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.