Can we add initial filter to segments

is there a way to create a segment with that starts with an initial filter

Example

I have a segment the show orders i want when the user clicks on the segment is loads with an initial filter which the user can clear if they want

Code


export const ordersNotInvoicedSegment = (app: INestApplication, collection: CollectionCustomizer<Schema, 'orders'>) => {
  const orderService: OrderService = app.get<OrderService>(OrderService, { strict: false })

  collection.addSegment('Orders Not Invoiced', async (context) => {
    const ordersNotInvoiced = await orderService.getOrdersNotInvoiced()

    return { field: 'id', operator: 'In', value: ordersNotInvoiced.map((r) => r.id) }
  })
}

is possible to add the filter when use clicks on the segment?

Hello @Hassan_Kourani

I’m not sure to understand what you’re trying to achieve ?

Could you not simply create multiple segments on your collection ? The base collection would still be accessible for the user to create his own filters if they wish.

If you are trying to limit what a user can see based on their team and whatnot you can use the feature Scope

Best regards,