0

I'm building a blog with Builder.io (really migrating it from DatoCMS), and I want to do a filter for them inside a fetch, as it was before. Before:

const { allBlogs } = await dato().GetAlBlogs({
 search,
 minYear,
 maxYear,
 dataProvided: dataProvided && {
        pattern: buildRegexp(dataProvided),
        caseSensitive: false
 },
});

Now, Builder.io has some query facillitie that accepts mongoDB query parameters. So I'm trying to do something like this:

const sets = await builder.getAll("open-dataset", {
    options: { noTargeting: true },
    limit: 100,
    query: { data: { title: { $regex: search && search }, date: { $gte: minYear && 
                    minYear, $lte: maxYear && maxYear } } },
 })

The issue is that I can't use javascript inside of it... I would like to do something like title.toLowerCase(): { $regex: search && searchtoLowerCase() and Number(date.slice(0, 4)): { $gte: minYear && minYear, $lte: maxYear && maxYear }.

The slice is because I want to cut the entire date to just the year.. because maxYear and minYear are just years as numbers (2006, 2022, 2021, etc).

Can anyone help me here please?? Thanks!

0 Answers0