firebase-realtime-database

Is there a way to store Key in class which I cast from Firebase object?

若如初见. 提交于 2019-12-28 07:07:22
问题 This is my database : [x] database -- > [+] students -----> [+] -KuGacomJymBwkcc7zlU (pushKey) -----------> Name - Jon -----------> Age - 21 I have Student.class : String name; String age; public Student(String Name, String Age) { this.name=Name; this.age=Age; } I read the information from firebase datasnapshot like this: Student newStudent = DataSnapshot.getValue(Student.class); When I do this I get the name and the age, but my question if there is a way to store the ID (pushKey) on the

Is there a way to store Key in class which I cast from Firebase object?

泄露秘密 提交于 2019-12-28 07:07:03
问题 This is my database : [x] database -- > [+] students -----> [+] -KuGacomJymBwkcc7zlU (pushKey) -----------> Name - Jon -----------> Age - 21 I have Student.class : String name; String age; public Student(String Name, String Age) { this.name=Name; this.age=Age; } I read the information from firebase datasnapshot like this: Student newStudent = DataSnapshot.getValue(Student.class); When I do this I get the name and the age, but my question if there is a way to store the ID (pushKey) on the

Sort firebase data in descending order using negative timestamp

岁酱吖の 提交于 2019-12-28 06:49:09
问题 above is a screenshot of my firebase database. i am trying to sort firebase data in descending order using negative timestamp. I 'm using the following command: const feedRef = database.ref('ducks') feedRef.orderByChild('timestamp').on('value', (snapshot, error) => { const feed = snapshot.val()}) i keep getting the feed in the same order as the database not in the descending order like i want.I think its not working because ducks endpoint doesnt have a child name timestamp how would i achieve

Does Firebase cache the data?

纵然是瞬间 提交于 2019-12-28 05:49:10
问题 I read somewhere a claim that Firebase caches the data. So I ran this test that reads a semi large volume of data (about 400KB). Here is the relevant code. firebase.initializeApp(config); var counter = 0; console.time('firebase answered in'); firebase.database().ref('texts').once('value',onData); function onData(snapshot){ console.timeEnd('firebase answered in'); counter ++; if(counter > 20) return; setTimeout(function(){ console.time('firebase answered in'); firebase.database().ref('texts')

Adding Firebase data, dots and forward slashes

橙三吉。 提交于 2019-12-28 05:46:05
问题 I try to use firebase db, I found very important restrictions, which are not described in firebase help or FAQ. First problem is that symbol: dot '.' prohibited in keys, i.e. firebase reject (with unknown reason) next: nameRef.child('Henry.Morgan@caribbean.sea').set('Pirat'); Second problem with forward slashes in your keys '/', when you try to add key like this {'02/10/2013': true} In firebase you can see: '02': { '10': { '2013': true } } Have you got any ideas how to solve it (automatically

Swift - How Can I use 'shouldChangeTextInRange' with Firebase for real time searching?

大城市里の小女人 提交于 2019-12-28 04:29:24
问题 I wonder that how creating Firebase matchesRegex query and listing current results using shouldChangeTextInRange . I have did it before in Parse for searching username or user fullname in Parse Cloud. If someone shed light my path to do it in Firebase, it would be great. // search updated func searchBar(searchBar: UISearchBar, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool { // find by username let usernameQuery = PFQuery(className: "_User") usernameQuery

Determining if Firebase didn't download data with startAt and endAT

做~自己de王妃 提交于 2019-12-28 03:14:05
问题 I'm trying to download data with Firebase. The issue is that I'm downloading the data based off of a timestamp. If their is only one item in my ListView that I'm populating, I want to get the next two hours worth of data from Firebase and if there isn't any data from the last two hours, I want to get the next two hours of data and so on until I get some additional data. The issue is that I don't exactly know how to determine if Firebase actually downloaded data. Because if data was downloaded

How to get child of child value from firebase in android?

我的未来我决定 提交于 2019-12-27 13:56:49
问题 How to get ZNAME value? Initially i need to compare key(Ex::Here ZONE_1) and then ZNAME need to be get. Thanks in advance... 回答1: To access a value in your database, you create a DatabaseReference for that location. Here are three references to locations in your database: DatabaseReference zonesRef = FirebaseDatabase.getInstance().getReference("ZONES"); DatabaseReference zone1Ref = zonesRef.child("ZONE_1"); DatabaseReference zone1NameRef = zone1Ref.child("ZNAME"); In this snippet: zonesRef

Append to array inside a Firebase Closure in Swift 3

佐手、 提交于 2019-12-26 12:29:10
问题 I am trying to append to an array inside a Firebase closure, I declared the array outside of the closure var CanJoinArray = [String]() But when I try to append to the array inside the closure: self.CanJoinArray.append("hello") and print it outside of the closure, print (CanJoinArray) it doesn't print. However, when I print the array inside the (inside) closure, it is able to append and print. How can I solve this? Thanks! ref.observeSingleEvent(of: .value, with: { (FIRDataSnap) in for child

How to structure code to deal with asynchronous Firebase snapshot? [duplicate]

空扰寡人 提交于 2019-12-26 09:32:25
问题 This question already has answers here : Returning method object from inside block (3 answers) Closed 2 years ago . I have an problem that I can not solve. A lot of questions are in JS and I don't really understand them. I'm using Firebase as my database for my IOS app and Swift. Here is my situation: I have a class file that contains functions that can retrieve values in my database. I'm calling these functions in some viewControllers . The values retrieved by these functions are immediately