# Smart segment pagination

**URL:** <https://community.forestadmin.com/t/smart-segment-pagination/3529>\
**Category:** Help me!\
**Created:** [October 13, 2021, 12:23pm UTC](https://community.forestadmin.com/t/smart-segment-pagination/3529 "2021-10-13T12:23:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![louisremi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/louisremi/32/165_2.png) [@louisremi](https://community.forestadmin.com/u/louisremi)\
**Post date:** [October 13, 2021, 12:23pm UTC](https://community.forestadmin.com/t/smart-segment-pagination/3529/1 "2021-10-13T12:23:37Z")

</div>

Hello,  
I have created a smart-segment and I’m trying to get pagination to work. The documentation shows how to set arbitrary limit to the number of results, but not how to implement proper pagination. How can I get the proper values I should set as `$limit` and `$skip`? My `where` function doesn’t seem to receive any useful arguments.

My project is using forest-express-mongoose 8.3.9

```javascript
{
    name: "Segment name",
    where: () => {
      return model.find({
          isActive: true,
        },
        [
          {
            $project: { _id: true },
          },
          {
            $sort: { updatedAt: -1 },
          },
          {
            $limit: "???",
          },
          {
            $skip: "???",
          },
        ])
        .then((spots) => ({
          _id: { $in: spots.map(({ _id }) => _id).filter(Boolean) },
        }));
    },
  };

```

---

<div class="post-metadata">

**Author:** ![morganperre](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/morganperre/32/1296_2.png) [@morganperre](https://community.forestadmin.com/u/morganperre)\
**Post date:** [October 13, 2021, 12:56pm UTC](https://community.forestadmin.com/t/smart-segment-pagination/3529/2 "2021-10-13T12:56:03Z")

</div>

Hello @louisremi ! 👋 Welcome to our community. 🎊

Clearly we are missing some documentation for **forest-express-mongoose**. [You can still find some information on this topic here](https://docs.forestadmin.com/documentation/reference-guide/segments/smart-segments).

But in this example the limit is manually set. I’ll double check with a colleague.

Kind regards,  
Morgan

---

<div class="post-metadata">

**Author:** ![louisremi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/louisremi/32/165_2.png) [@louisremi](https://community.forestadmin.com/u/louisremi)\
**Post date:** [October 13, 2021, 1:04pm UTC](https://community.forestadmin.com/t/smart-segment-pagination/3529/3 "2021-10-13T13:04:51Z")

</div>

I realized that I could simply write

```javascript
{
    name: "Segment name",
    where: () => {
      return {
        isActive: true,
      };
    },
  };

```

And my segment would work equally well, with pagination and even search working as expected in Forest Admin. I’m wondering why the documentation is much more complex than that.

---

<div class="post-metadata">

**Author:** ![morganperre](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/morganperre/32/1296_2.png) [@morganperre](https://community.forestadmin.com/u/morganperre)\
**Post date:** [October 13, 2021, 1:17pm UTC](https://community.forestadmin.com/t/smart-segment-pagination/3529/4 "2021-10-13T13:17:32Z")

</div>

Perfect @louisremi 🙏

I think the documentation is partially outdated. I will forward your feedback to the team.

Searching, filtering and pagination are automatically handled by Forest Admin. The only thing you have to return in your smart segment configuration, is the actual filter to scope your data.

Have a nice day.

Kind regards,  
Morgan
