Skip to Main Content
Builder.io Ideas
Created by Ersin Akinci
Created on Jan 9, 2023

Allow aggregation operations: $cond, $ifNull, etc.

I want to query content items using the query syntax but manipulate the set of returned items based on certain conditions.

My main use case is that I want to query for a URL path and a custom targeting attribute. If there's a content item for that path AND the specified attribute, then return it. If there isn't a content item for that path AND the specified attribute, then fall back to a content item that matches the path but doesn't have the custom attribute set.

In MongoDB, we'd accomplish this using aggregation with something like $cond or $ifNull. However, Builder doesn't support these. I'd love to see support in the content API for these and other aggregation operations.

  • Attach files