Skip to main content

Segments

By default, every models you have configured in the adminmate.js configuration file is fully accessible from your back-office.

But in many cases you will need to have pre-configured Segments of your data, directly accessible from your back-office.

Segments are simply subset of your data you can set thought the segments property.

Example: You have a user model and you want to configure a segment that will show only the last 7 days signup. You can use the segment property as bellow.

{
slug: 'users',
model: models.users,
segments: [
{
label: 'Last week signup',
code: 'last_week_signup',
query: {
created_date: {
$gte: global._moment().subtract(1, 'week')
}
}
}
]
}

This example is base on the Mongoose syntax. You will have to use the proper query syntax depending if you are using Sequelize or Mongoose.