Skip to content

Latest commit

 

History

History
executable file
·
53 lines (39 loc) · 948 Bytes

firebase.md

File metadata and controls

executable file
·
53 lines (39 loc) · 948 Bytes

Firebase

Basics

  • Firebase = Company
  • Firebase Firestore = Realtime, noSQL, Cloud Database

Setup

db.collection(collectionName)
  .where(key, comparison, value) // additional selector ("city", "===", "Stuttgart")
  .orderBy(key, order) // additional order ("name", "desc")
  .limit(number) // additional limit (3)
  .get(); // getting a snapshot, iterate and .data()
  • realtime updating data:
db.collection(collectionName)
  .onSnapshot((snap) => {
    let changes = snap.docChanges();
    changes.forEach((change) => {}});
  });
  • add data:
db.collection(collectionName).add(obj);
  • delete data:
db.collection(collectionName)
  .doc(id)
  .delete();
  • update data:
db.collection(collectionName)
  .doc(id)
  .update({ key: value });