# Query section model content-entries based on locale using MongoDB Operators

**URL:** <https://forum.builder.io/t/query-section-model-content-entries-based-on-locale-using-mongodb-operators/6019>\
**Category:** Technical Questions\
**Tags:** nextjs, query, locale, section, targeting\
**Created:** [July 19, 2024, 3:51pm UTC](https://forum.builder.io/t/query-section-model-content-entries-based-on-locale-using-mongodb-operators/6019 "2024-07-19T15:51:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [July 19, 2024, 3:51pm UTC](https://forum.builder.io/t/query-section-model-content-entries-based-on-locale-using-mongodb-operators/6019/1 "2024-07-19T15:51:49Z")

</div>

To query the builder section model content based on locale using MongoDB operatores, you will need to use specific MongoDB operators within your query. The key parameters to focus on are `query.query.$elemMatch.$and[0].property` and `query.query.$elemMatch.$and[0].value`. These parameters together form a query that filters content where the `locale` property equals `fr`.

 ![Screenshot 2024-07-19 at 9.14.50 PM](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/e/ee2bd686506653e4d0040c0a804348919e8d4277.png)

### REST API Example

Here is an example of how you can use the REST API to query product pages where the locale is `fr`:

```auto
https://cdn.builder.io/api/v3/content/your-model-name?apiKey=YOUR-API-KEY&query.query.$elemMatch.$and[0].property=locale&query.query.$elemMatch.$and[0].operator=is&query.query.$elemMatch.$and[0].value=fr&limit=100&fields=query,id,name

```

### Query Breakdown

In this query, we use the following structure:

```auto
{
  "query": {
    "$elemMatch": {
      "$and": [
        {
          "property": "locale",
          "value": "fr"
        }
      ]
    }
  }
}

```

### Next JS example

```auto
const builderModelName = "product-page";
  const content = await builder
    // Get the page content from Builder with the specified options
    .get(builderModelName, {
      enrich: true,
      options: {
        cachebust: true,
        noTargeting: true,
      },
      query: {
        "query": {
          $elemMatch: {
            $and: [
              {
                "property": "locale",
                "value": "fr"
              }
            ]
          }
        }
      },
    })
    // Convert the result to a promise
    .toPromise();

```

This query ensures that we filter the content pages to include only those where the `locale` property is set to `fr`.

**Note:** You should be able to query the same using just `userAttributes.locale=whatever`

For more detailed information on querying [Builder.io](http://Builder.io)’s Content API, you can refer to the Content API Documentation.

Thanks,
