2

Below is how the data is structured. So I wan't to query user and query equal to the uid of the user.

poopy

let queryRef = FIRDatabase.database().reference().child("user") queryRef.queryEqualToValue(FIRAuth.auth()!.currentUser!.uid)observeEventType(.Value, withBlock: { (snapshot) -> Void in self.userDict.append(snapshot.value as! NSDictionary) print(snapshot.value as! NSDictionary) dispatch_async(dispatch_get_main_queue(), { () -> Void in self.searchTableView.reloadData() print(self.userDict) SwiftLoader.hide() queryRef.removeAllObservers() }) }) 

I am able to print the values of first name and last name but not address or image. Also can't save as NSDictionary. If I take out queryEqualToValue it works fine, but I get the values of all users.

1 Answer 1

4

You might be looking for something like this:

let queryRef = FIRDatabase.database().reference().child("user") queryRef.child(FIRAuth.auth()!.currentUser!.uid).observeEventType(.Value, withBlock: { (snapshot) -> Void in print(snapshot.value as! NSDictionary) } 
Sign up to request clarification or add additional context in comments.

1 Comment

Good answer! It's an important thing to keep in mind with Firebase (and most any NoSQL database): direct access is faster/more scalable than a query.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.