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

Documents list not being sorted by publishedAt data #231

Closed
avitorio opened this issue Jun 12, 2024 · 3 comments
Closed

Documents list not being sorted by publishedAt data #231

avitorio opened this issue Jun 12, 2024 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@avitorio
Copy link
Owner

Based on this discussion.

Lists are not currently being sorted by date.

@avitorio avitorio added bug Something isn't working good first issue Good for newcomers labels Jun 12, 2024
@joaoalberto-dev
Copy link

@avitorio looks like this issue was fixed here. Do you mind closing it?

@avitorio
Copy link
Owner Author

@joaoalberto-dev ah yes, thanks for the reminder!

@h34lthbybr33
Copy link

Just want to call out, while the fix works on the client it doesn't remediate a core issue on the server. Because this field (publishedAt) is typed as a string, sorting becomes wonky when you try to filter through db.find({ ... }).

Assuming:

type BlogPost = OstDocument & { ... };

I would expect the following to work:

const posts = await db.find<({ collection: 'posts', publishedAt: { $lte: Date.now().toString() } })

Because it's a string, the filter really can't do much other than a string comparison (which inverts the logic now to use $gte vs $lte).

I came across this while trying to "future publish" (set date for future, not caring about sensitivity of the post, just that it didn't bubble up to UX "formally" until the date had passed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants