( currentItems: Entity<Data, View>[], store: EntityStore<Data, View>, queryObject: FindObjectPartInput<Data & View> )
| 23 | type MaybeObservableArray<T> = IObservableArray<T> | T[]; |
| 24 | |
| 25 | function getRemainingItemsAfterApplyingQueryFields<Data, View>( |
| 26 | currentItems: Entity<Data, View>[], |
| 27 | store: EntityStore<Data, View>, |
| 28 | queryObject: FindObjectPartInput<Data & View> |
| 29 | ) { |
| 30 | let passingItems = currentItems; |
| 31 | |
| 32 | const itemsMatchingEachValue: Entity<Data, View>[][] = []; |
| 33 | |
| 34 | for (const queryKey of typedKeys(queryObject)) { |
| 35 | const queryValue = queryObject[queryKey] as AnyKeyIndexInput<Data & View>; |
| 36 | const index = store.getPropIndex(queryKey); |
| 37 | |
| 38 | const itemsMatchingValue = index.find(queryValue); |
| 39 | |
| 40 | // If no items are matching some value - there is no point in continuing. |
| 41 | if (itemsMatchingValue.length === 0) return []; |
| 42 | |
| 43 | itemsMatchingEachValue.push(itemsMatchingValue); |
| 44 | } |
| 45 | |
| 46 | return getArraysCommonPart(passingItems, ...itemsMatchingEachValue); |
| 47 | } |
| 48 | |
| 49 | export function findInSourceByObjectInput<Data, View>( |
| 50 | source: MaybeObservableArray<Entity<Data, View>>, |
no test coverage detected