Replies: 2 comments 8 replies
-
I would suggest using a functional data processing library like https://github.com/remeda/remeda instead, I'm not sure this is necessary to include directly in content collections? Is there a reason why the library I linked, or something more well-used like Lodash, wouldn't work? |
Beta Was this translation helpful? Give feedback.
4 replies
-
I should have done some research before writing that comment. Nuxt and lume are the ones that do what I'm talking about. Gatsby does querying but it uses GraphQL in a magic way. @jasikpark |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
Can we please get a library that works like a query builder for Content Collections? Developers need a library that allows them to declaratively filter, sort, and group limit fields in content collections.
Background & Motivation
Content Collections allows it's user to get lots of collections but it only gives you a callback function for querying. This idea is good but and developers have lots of flexibility but many times developers have to do other other things with the data they are querying and are forced to implement their own solutions for handling how the data is sorted.
What are the problems that this RFC sets out to solve?
The problem that is meant to be solved by this RFC is data querying and sorting.
Scenario One
Lets say the user wants to get a collection of blogs by a certain Author with and wants to see the current ones by that person. The code for that would look something like this.
If I wanted to then group it by the published Date I'd have to then I'd have to do this
The above examples require too much boilerplate code. The second example should have been written by using a
Map
but you get the point.Scenario Two
Lets say that I have to be able to get the first five of something or skip some collections by 2. You'd have to write this.
Scenario Three
If I wanted to select some fields from a collection I would have to write.
As you can see this is a lot of work and not so easy to figure out. The hardest part for me was the grouping. By creating an official library that abstracts away all of this developers can be more productive.
Goals
Example
In this example use Collection is used behind the scenes
**For a more in depth example go to [Blog Example on Stackblitz](https://stackblitz.com/edit/withastro-astro-blog-with-ft-pt
Beta Was this translation helpful? Give feedback.
All reactions