(snapshot, query)
| 48 | }; |
| 49 | |
| 50 | function querySnapshot(snapshot, query) { |
| 51 | // Never match uncreated or deleted snapshots |
| 52 | if (snapshot.type == null) return false; |
| 53 | // Match any snapshot when there is no query filter |
| 54 | if (!query.filter) return true; |
| 55 | // Check that each property in the filter equals the snapshot data |
| 56 | for (var queryKey in query.filter) { |
| 57 | // This fake only supports simple property equality filters, so |
| 58 | // throw an error on Mongo-like filter properties with dots. |
| 59 | if (queryKey.includes('.')) { |
| 60 | throw new Error('Only simple property filters are supported, got:', queryKey); |
| 61 | } |
| 62 | if (snapshot.data[queryKey] !== query.filter[queryKey]) { |
| 63 | return false; |
| 64 | } |
| 65 | } |
| 66 | return true; |
| 67 | } |
| 68 | |
| 69 | // sortProperties is an array whose items are each [propertyName, direction]. |
| 70 | function snapshotComparator(sortProperties) { |
no outgoing calls
no test coverage detected
searching dependent graphs…