Firebase documentation says we can have up to 200k connection limit per database,
Because we can have several references of that database in the project, I couldn't clearly understand what counts as a connection?
struct DatabaseService { // class ?
let db = Database.database()
let ref = db.reference("/path")
let child = db.reference().child("/path")
// what is the difference between ref and child? If no difference why do we have both of them?
let db2 = Database.database()
let ref2 = db2.reference()
// db and db2 counts as one connection or two ?
func observeRef() {
ref.observe(.value) { snap in print("called") }
}
func observeRef2() {
ref2.observe(.value) { snap in print("called") }
}
func removeAllObservers() {
ref.removeAllObservers() // will this also remove ref2.observe?
}
}
Should we create one database service class share its reference across app as singleton or is it okay to create a that service as a struct and create it whenever you need across the app? Will having one instance or having structs affect our database connection count?