firebase-realtime-database

How do I relate new data to a currently logged in user in Firebase?

扶醉桌前 提交于 2020-07-31 04:19:55
问题 I want to add a student list to my Firebase realtime database. When a teacher adds a new student, I want the currently logged-in teachers ID to relate to the student they just added. When I compile the following I get my "Student Added" toast on the emulator but nothing shows up on Firebase - no new parent of "students" and no new entries. Can someone see where I'm going wrong? I think using datasnapshot to get thecurrentUserId from Firebase might be long-winded but when I just used the

How do I relate new data to a currently logged in user in Firebase?

橙三吉。 提交于 2020-07-31 04:19:47
问题 I want to add a student list to my Firebase realtime database. When a teacher adds a new student, I want the currently logged-in teachers ID to relate to the student they just added. When I compile the following I get my "Student Added" toast on the emulator but nothing shows up on Firebase - no new parent of "students" and no new entries. Can someone see where I'm going wrong? I think using datasnapshot to get thecurrentUserId from Firebase might be long-winded but when I just used the

Firebase security rules - is Auth generated UID ought to be kept secret? [duplicate]

…衆ロ難τιáo~ 提交于 2020-07-30 01:54:12
问题 This question already has an answer here : Firebase - Is auth.uid a shared secret? (1 answer) Closed 2 years ago . I've been reading Firebase Realtime Database Security Rules guides (https://firebase.google.com/docs/database/security), and I'm a bit confused with regards to should I keep the UID generated by the Firebase Auth (lets say if my App users use Facebook to authenticate themselves) secret? I have this kind of data structure: users UID Lots of nodes of personal data to be read

How to get data from wildcard in firebase cloud functions

你离开我真会死。 提交于 2020-07-29 06:08:34
问题 Assuming that I trigger events on the following ref('/users/{userId}/items/{newItem}') I want to get a value from inside the wildcard userId I have tried var token = event.params.userId.token but it return to be undefined Any suggestions? 回答1: Token is not a parameter returned automatically from trigger events. In trigger wild cards only parameters corresponding directly to the wildcard are returned. So You need to do the following if you want to use the var userId = event.params.userId And

How to get data from wildcard in firebase cloud functions

安稳与你 提交于 2020-07-29 06:08:01
问题 Assuming that I trigger events on the following ref('/users/{userId}/items/{newItem}') I want to get a value from inside the wildcard userId I have tried var token = event.params.userId.token but it return to be undefined Any suggestions? 回答1: Token is not a parameter returned automatically from trigger events. In trigger wild cards only parameters corresponding directly to the wildcard are returned. So You need to do the following if you want to use the var userId = event.params.userId And

Read Data Firebase assign value

…衆ロ難τιáo~ 提交于 2020-07-28 04:52:08
问题 I want to assign the data I have read in the Firebase database to the values I have given in the code. The data is being read in the code I have given, but the values are not being assigned. I want to assign deviceroom1, deviceRoom2, deviceRoom3, deviceRoom4. var deviceRoom1: String = "" var deviceRoom2: String = "" var deviceRoom3: String = "" var deviceRoom4: String = "" var deviceRoom5: String = "" func fetchDevies(){ let ref = Database.database().reference().child(self.chip1InfoString!)

Flutter Firebase Database wrong timestamp order

被刻印的时光 ゝ 提交于 2020-07-26 03:30:52
问题 I'm trying to set timestamp into firebase realtime database but when I retrieve, not ordering by timestamp. I did like so. FirebaseDatabase.instance.reference().child('path').push().set({ 'timestamp': ServerValue.timestamp }); This is the node Then I retrieve like so. FirebaseDatabase.instance.reference().child('path').orderByChild('timestamp').once().then((snap) { print(snap.value); }); but output is this {-LJhyfmrWVDD2ZgJdfMR: {timestamp: 1534074731794}, -LJhyWVi6LddGwVye48K: {timestamp:

Flutter Firebase Database wrong timestamp order

空扰寡人 提交于 2020-07-26 03:26:30
问题 I'm trying to set timestamp into firebase realtime database but when I retrieve, not ordering by timestamp. I did like so. FirebaseDatabase.instance.reference().child('path').push().set({ 'timestamp': ServerValue.timestamp }); This is the node Then I retrieve like so. FirebaseDatabase.instance.reference().child('path').orderByChild('timestamp').once().then((snap) { print(snap.value); }); but output is this {-LJhyfmrWVDD2ZgJdfMR: {timestamp: 1534074731794}, -LJhyWVi6LddGwVye48K: {timestamp:

Indexing unknown nodes in Firebase

一笑奈何 提交于 2020-07-23 15:18:21
问题 My data structure is like this: firebase-endpoint/updates/<location_id>/<update_id> each location has many updates that firebase adds as "array" elements. How can I index on the "validFrom" property of each update if the location_id is unknown before insertion into the databse? { "rules": { "updates": { "<location_id>": { // WHAT IS THIS NODE SUPPOSED TO BE? ".indexOn": ["validFrom"] } } } } data structure sample { "71a57e17cbfd0f524680221b9896d88c5ab400b3": { "-KBHwULMDZ4EL_B48-if": { "place

Indexing unknown nodes in Firebase

一曲冷凌霜 提交于 2020-07-23 15:18:10
问题 My data structure is like this: firebase-endpoint/updates/<location_id>/<update_id> each location has many updates that firebase adds as "array" elements. How can I index on the "validFrom" property of each update if the location_id is unknown before insertion into the databse? { "rules": { "updates": { "<location_id>": { // WHAT IS THIS NODE SUPPOSED TO BE? ".indexOn": ["validFrom"] } } } } data structure sample { "71a57e17cbfd0f524680221b9896d88c5ab400b3": { "-KBHwULMDZ4EL_B48-if": { "place