Skip to content

Instantly share code, notes, and snippets.

@sbatson5
Last active November 4, 2019 19:32
Show Gist options
  • Save sbatson5/c9d018a3d46de1ce6be770848f88e47f to your computer and use it in GitHub Desktop.
Save sbatson5/c9d018a3d46de1ce6be770848f88e47f to your computer and use it in GitHub Desktop.
Simple firebase example of conditional query
const firebase = require('firebase');
function maybeGetEventsByState(state) {
const db = firebase.firestore();
const query = db.collection('events');
if (state) {
query = query.where('state', '==', state);
}
return query.get();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment