Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MinAt and MaxAt static methods #58

Closed

Conversation

itsmuntadhar
Copy link

@itsmuntadhar itsmuntadhar commented Sep 17, 2023

Description

This PR adds a couple of static methods that work similarly.

MinAt:
Generates the minimum possible Ulid given a DateTimeOffset

MaxAt:
Generates the maximum possible Ulid given a DateTimeOffset

Reason

We have been using Ulid and this library for a while and it's quite great with pagination. But in order to use that, we sometimes have to do var idGte = Ulid.NewUlid(createdAtGte, new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }) to compare it against the primary key

Solution

Theses minute methods would make the code more readable e.g.: var idGte = Ulid.MinAt(createdAtGte)

@neuecc
Copy link
Member

neuecc commented Sep 22, 2023

Thank you.
Given that you can pass randomness, I believe you can use a workaround.
Considering its name and nature, it might be difficult to include it as a lib standard.

@neuecc neuecc closed this Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants