Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

93
Views
Using javascript inside a query fetch

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!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!