Last active
November 4, 2019 19:32
-
-
Save sbatson5/c9d018a3d46de1ce6be770848f88e47f to your computer and use it in GitHub Desktop.
Simple firebase example of conditional query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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