What is the exact way of Firebase (3.2.0) Querying with Swift (2.0)?
Date : March 29 2020, 07:55 AM
Hope this helps I have been trying to query through my firebase database by using their guides but I'm unable to return results appropriately. If someone can point out what I'm doing wrong or correct me, it will be very helpful. , I continued testing and changed the way i would get my result by MyQuery1.observeSingleEventOfType(.Value, withBlock: {
snapshot in
print("************")
print("Ordered by Value")
for snap in snapshot.children {
print(snap);
}
})
Ordered by Value
Snap (Okay) 1
Snap (Lets) 3
Snap (beep) 4
Snap (boop) 11
Snap (Alright) 24
Snap (Gamma) Alphaa
Snap (Beta) Betaa
Snap (Delta) Deltaa
Snap (Epsilon) Epsilonn
Snap (Eta) Etaa
Snap (Alpha) Gammaa
Snap (Iota) Iotaa
Snap (Theta) Thetaa
Snap (Zeta) Zetaa
|
Swift and Firebase querying the database
Tag : swift , By : Comfly
Date : March 29 2020, 07:55 AM
Hope that helps I am trying to create a tableView of chats the user is a part of. I was following the firebase tutorials on their site and they said to easily get a list of chat rooms the user is a part of to create a child and add the names of the rooms to that child. , The code you are using is the challenge. Here's a simplified version: let usersRef = firebase.child("users")
let thisUser = usersRef.childByAppendingPath(fUID)
let thisUsersRooms = thisUser.childByAppendingPath("rooms")
thisUsersRooms.observeSingleEventOfType(.Value, withBlock: { snapshot in
if ( snapshot.value is NSNull ) {
print("not found")
} else {
for child in snapshot.children {
let roomName = child.key as String
print(roomName) //prints each room name
self.roomsArray.append(roomName)
}
self.myRoomsTableView.reloadData()
}
})
|
Querying Firebase with Swift 3.0
Date : March 29 2020, 07:55 AM
help you fix your problem You need to use queryOrderedByChild to createdAt and than use equalTo Today let ref = FIRDatabase.database().reference().child("thoughts").queryOrdered(byChild: "createdAt").queryEqual(toValue : "Today")
ref.observe(.value, with:{ (snapshot: FIRDataSnapshot) in
for snap in snapshot.children {
print((snap as! FIRDataSnapshot).key)
}
})
|
Firebase and querying for a term in Swift
Tag : swift , By : Tim Benninghoff
Date : March 29 2020, 07:55 AM
To fix the issue you can do Since you're using queryEqualToValue, you will only get results where the userComment matches exactly with the value you specified. If you want results where userComments starts with the value, you should use a combination of queryStartingAtValue and queryEndingAtValue: DataService.dataService.BASE_REF.child("Posts").
child(selectedComment.commentKey).child("comments").
queryOrderedByChild("userComment")
.queryStartingAtValue(comment). queryEndingAtValue(comment+"\uF8FF")
observeSingleEventOfType(.Value, withBlock: { (snapshot) in
|
Swift Firebase querying
Tag : swift , By : Chris Tattum
Date : March 29 2020, 07:55 AM
To fix this issue You have to define Firebase Database indexes in the location where you execute the query. So that is one level higher than where you currently have it: {
"rules": {
"users": {
".indexOn": ["email"],
".read": "auth != null",
"$uid": {
".write": "$uid === auth.uid",
}
}
}
}
|