firebase-realtime-database

Firebase Real Time Database Structure for File Upload

走远了吗. 提交于 2019-12-31 04:11:38
问题 I am working on my first Firebase project using AngularFire2. Below is the overall design of my learning project. Users uploads photos and it's stored in the Firebase storage as images. The uploaded photos are listed in the homepage sorted based on timestamp. Below is the structure that I have now when I started. But I feel difficulty when doing joins. I should be able to get user details for each uploads and able to sort uploads by timestamp. User: - Name - Email - Avatar Uploads: - ImageURL

Should FirebaseDatabase.getInstance() be used sparingly?

浪子不回头ぞ 提交于 2019-12-31 04:05:23
问题 For example when I use a SQLiteDatabase in android, it is generally not a good idea to open/close lots of SQLiteDatabase helpers. Instead it is better to create a sort of singleton which makes sure you only have 1 database open. Say I have a class with static methods doing lots of Firebase operations which require a DatabaseReference. example: static void checkIfUserIsMatched(...) static void notifyUser(...) static void modifyUser(...) Is it OK to call FirebaseDatabase.getInstance() inside

Pulling Data From Firebase Issue

孤街醉人 提交于 2019-12-31 04:04:44
问题 Novice programmer, currently working on an ios app using firebase as our backend. I'm trying to grab values from the firebase database to populate a TableView, but there are two issues. Firstly, it seems to ignore the ref.observeSingleEvent that I set up to try and retrieve the values, and while running the console ouputs: 2016-10-16 00:26:02.635: STOP!! Will reset deviceID from memory. 2016-10-16 00:26:02.635: Failed to fetch default token Error Domain=com.firebase.iid Code=6 "(null)"

Firebase Can't call equalTo() and startAt() combined [duplicate]

谁说胖子不能爱 提交于 2019-12-31 04:03:29
问题 This question already has answers here : Query based on multiple where clauses in Firebase (4 answers) Closed 2 years ago . I have a Firebase database that I'm trying to query, however I'm getting a error at run time saying java.lang.IllegalArgumentException: Can't call equalTo() and startAt() combined My database is as follows //DB refrence myBikesDB = FirebaseDatabase.getInstance().getReference().child("Bikes Registered By User").child(ronan); //query query = myBikesDB.orderByChild(

Can I determine if query does NOT find any children with values within a specified range?

霸气de小男生 提交于 2019-12-31 03:59:08
问题 Can I somehow determine if no children at ref exist with vals between -1 and newTotal ? Here's what I was hoping would work. The callback runs if children exist within the query. ref.orderByValue().startAt(-1).endAt(newTotal).limitToLast(1).once("child_added", function(snap){ /* Runs only when query yields a result */ if (snap.exists()){ ... } else { ... } }); newTotal is 0 or any positive integer. 回答1: The child_ events will only fire when the relevant child exists/changes. To detect when

Extend Firebase User

旧街凉风 提交于 2019-12-31 03:54:13
问题 After authenticating the user and updating the FirebaseUser table, I would need to save other extra data such as age, gender, address etc. I would like to use the Realtime Database by creating a user node and hooking to the FirebaseUser through UID. Is my way of working correct? I would be grateful if somebody can help me understand. Thank you. 回答1: A common practice in Firebase is to create for your user a helper class ( model class , POJO class ) and this the corect way to achieve this:

Firebase Retrieve Current Child then Set as Child of another Child Android

China☆狼群 提交于 2019-12-31 03:24:11
问题 ** EDITED ** I need help with Firebase. What I need to do is: Create a new database reference named Tokens (In line with Clients and Workers), and under Tokens; Create another new database reference based on the child of the current user (e.g. Carpenters, Plumbers, or Electricians) Current code: FirebaseDatabase db = FirebaseDatabase.getInstance(); DatabaseReference tokens = db.getReference(Common.token_table); Token token = new Token(FirebaseInstanceId.getInstance().getToken()); //if user is

Can't get the return value from a method that retrieves data from Firebase Realtime database to use it in following line of code [duplicate]

允我心安 提交于 2019-12-31 03:09:11
问题 This question already has answers here : How to return DataSnapshot value as a result of a method? (5 answers) Closed last year . I'm quite new to Firebase Realtime database. I'm working on an android app which requires data to be retrieved from Firebase Realtime DB. I've been able to retrieve data using the Firebase listener methods in most occasions but on one occasion, I've found it unable to get a value in the way that I want (I think because of the asynchronous nature). SCENARIO:- I have

Firebase - Get Random Child From Database Node

萝らか妹 提交于 2019-12-31 02:43:29
问题 I'm writing a Firebase Cloud Function that is called from an Android app. The function should get a random user from the users node in the Database (Any random user but not the one who sent the request) and return it to the client. The problem is that the data is not structured as an array (And it should not be and can't be). So I can't pick a random number and read that node, I also don't want to read all the users node and iterate it because it contains a lot of users and that would be time

Firebase database for Android - write events when offline, using persistence

假装没事ソ 提交于 2019-12-31 02:30:46
问题 As stated in the title, I am using the Firebase Realtime Database, with persistence enabled . As stated in the guide, By enabling persistence, any data that the Firebase Realtime Database client would sync while online persists to disk and is available offline, even when the user or operating system restarts the app. This means your app works as it would online by using the local data stored in the cache. Listener callbacks will continue to fire for local updates . While this happens with the