Skip to content

Instantly share code, notes, and snippets.

@bmass02
Created November 7, 2017 05:20
Show Gist options
  • Save bmass02/bd9015d829ace9d0574a9d8f01fed9f2 to your computer and use it in GitHub Desktop.
Save bmass02/bd9015d829ace9d0574a9d8f01fed9f2 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Testing Firestore</title>
</head>
<body>
<script src="https://www.gstatic.com/firebasejs/4.6.1/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.6.1/firebase-firestore.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyDLzB9l-EhojB4ibze5ryw5Sp-v36_ZElE",
authDomain: "testing-out-firestore.firebaseapp.com",
databaseURL: "https://testing-out-firestore.firebaseio.com",
projectId: "testing-out-firestore",
storageBucket: "testing-out-firestore.appspot.com",
messagingSenderId: "925460159146"
};
firebase.initializeApp(config);
firebase.firestore().collection('collectionId').orderBy('index', 'desc').limit(2).onSnapshot((snapshot) => {
console.log(snapshot.size)
snapshot.docs.forEach((doc) => {
console.log(doc.data())
})
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment