MCPcopy Index your code
hub / github.com/share/sharedb / querySnapshot

Function querySnapshot

test/BasicQueryableMemoryDB.js:50–67  ·  view source on GitHub ↗
(snapshot, query)

Source from the content-addressed store, hash-verified

48};
49
50function 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].
70function snapshotComparator(sortProperties) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…