omit with condition
I want to only omit certain fields if a condition in the same thing I'm querying is true
example:
Solution:Jump to solution
---
Here is the
omitArray
function for anyone finding this later
```ts
export function omitArray<Data extends object, Keys extends keyof Data>(
data: Data[],...7 Replies
Not currently possible. As a work around, you could put the condition inside your where clause. Query once where channel type is 1 (and omit name). Query another time where channel type is not 1 and don’t omit
Hmm this would be possible but it intentionally orders the list to type 1 and then type 0
Hm yes, that’s true. How large are these data sets? Would you be paginating?
Pretty small for now, so no paginating
You could then pull everything in and shuffle it. It’s not an ideal solution but it would at least be a proof of concept
Otherwise, you could just pull data from your db and then iterate through setting name to undefined where needed
Both are not great options, unfortunately
Hmm I need the data in the original order.
I do have an
omitArray
function which removes a property from all indecies of an array I guess I should use that then. Thought there might be a native solution.Solution
---
Here is the
omitArray
function for anyone finding this later