Wednesday 20 February 2019

Firebase cloud database

Realtime database: app talks directly to the database and listens to the changes instead of app-> server-> database


Firestore:
tutorial link: https://codelabs.developers.google.com/codelabs/firestore-ios/#0
collection -> db
document -> table
firstPost = firebase.app().firestore().collection('posts').doc('firstpost')


Retrieve data:
firstPost.get().then(doc......


Listen to changes:
firstPost.onSnapshot(doc => {
})


query can be applied to the records: order, filter


restrict access to certain records: add rules in console








Realtime database VS Firestore
Pricing!
Realtime database suits for simple structure data but read/write very frequently: realtime chat app
Firestore: complicated structure, not quite frequent read/write

No comments:

Post a Comment