firebase-realtime-database

Try to understand how well can denormalize work with firebase database in my scenario

自古美人都是妖i 提交于 2020-01-07 06:32:51
问题 So basically i'm building all previous application with mysql to store data and consider switch to firebase database which make me feel a little bit crazy. I'm trying to implement a chat system but there is some trouble when understanding how it work. Based on the Denormalizing Your Data is Normal I get the idea and concept on how does denormalize work. I know I could just create a message structure to store chat message like below (the example from doc) "messages": { "one": { "m1": { "name":

Try to understand how well can denormalize work with firebase database in my scenario

大憨熊 提交于 2020-01-07 06:32:09
问题 So basically i'm building all previous application with mysql to store data and consider switch to firebase database which make me feel a little bit crazy. I'm trying to implement a chat system but there is some trouble when understanding how it work. Based on the Denormalizing Your Data is Normal I get the idea and concept on how does denormalize work. I know I could just create a message structure to store chat message like below (the example from doc) "messages": { "one": { "m1": { "name":

Polymer 1.x: How to reverse order of records returned by <firebase-collection>

天涯浪子 提交于 2020-01-07 05:05:11
问题 How do I reverse the order of records returned by <firebase-collection> as follows: <firebase-collection id="foo" order-by-child="bar"> ? Can I do it declaratively? Or do I need to call an imperative method like maybe... this.$.foo = this.$.foo.reverse(); https://elements.polymer-project.org/elements/firebase-element?active=firebase-collection Note: I'm using <iron-list> and not <template is="dom-repeat"> . 回答1: Simplest is just to use a <dom-repeat> with an inverse sort I believe. sort.

How to come up with students and teacher relation in Firebase?

送分小仙女□ 提交于 2020-01-07 04:58:27
问题 I am trying to create just basic data structure for students -> teacher relation. Students -> Teacher (many to many) Each students can have many teachers Users uid1: type: student name: Alex Smith teachers: [uid5: true, uid4: true ] //is it better to do it like this? uid2: type: student name: Michael A teachers: [ uid5: true] uid3: type: student name: Michael A teachers: [uid5: true] uid4: type: teacher name: Alex Smith teacher: [uid3: true] //is it better to use their uid? uid5: type:

ServerValue.TIMESTAMP returning 2 values?

我们两清 提交于 2020-01-07 03:48:22
问题 I use the following code to add a timestamp to a message: Map<String, Object> postValues = post.toMap(); postValues.put("timeStamp", ServerValue.TIMESTAMP); On the client side two timestamp values are printed out (one for the local creation date and one for the value from the server I think). How do I only print out the value which came from the server? Side-note for Frank: The code below is called when the user presses the 'send' button. Thus, the messageViewHolder gets updated twice in my

Android Firebase weird limitToLast(1) behaviour

徘徊边缘 提交于 2020-01-07 03:13:07
问题 I'm using Firebase for Android and faced some misbehaviour of limitToLast() query. What I'm trying to do, is to get the last child of list, and iterate through other children of this node: database.getReference().child("draws").limitToLast(1).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { for(DataSnapshot snap: dataSnapshot.getChildren()){ //Some work snap.getValue() } } @Override public void onCancelled(DatabaseError

Android Firebase query data

落爺英雄遲暮 提交于 2020-01-07 03:01:10
问题 Im trying to query data from firebase database.Below images show data structure. .Im trying to query messages by data(long value is the time in milli seconds).Below is the code : database.child("Market").child("data").child("messages").orderByKey().startAt("1473777076600").addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { MessageFirebaseHelper data = dataSnapshot.getValue(MessageFirebaseHelper.class); Object[] messageKeys

Access Data Outside of Closure, Firebase ObserveSingleEvent // SWIFT

女生的网名这么多〃 提交于 2020-01-07 02:51:35
问题 When I first asked this question I hadn't really done my research. But after 20+ hours on this, I have structure exactly like in Firebase docs. But, I can't access any of the data outside of the closure. Here is the struct where the data should be written in to: struct UserStruct { let name : String! let age : String! } And when it gets called, everything is written perfect in the database, inside the closure it doesn't print nil, it does print the actual value obviously. I have already tried

Firebase .on() listener causes Cordova iOS app crash

孤街醉人 提交于 2020-01-07 02:48:31
问题 I have made a blank, brand new Cordova app (-v 6.3.1), and built for iOS. The app does nothing except the following: var ref = new Firebase('url-to-firebase-leaf-node-with-4000-children'); ref.on("child_added", function(child, prev) { console.log("here"); }); Deploy to iPhone. The app crashes, and Xcode cites the following: WebThread (7): EXC_BAD_ACCESS (code=1, address=0xbbadbeef) inside of bmalloc::VMHeap::grow() . If I do this rather: var ref = new Firebase('url-to-firebase-leaf-node-with

Empty ArrayList - Firebase Data Retrieval

大憨熊 提交于 2020-01-07 02:46:11
问题 I am currently trying to run a query on my firebase DB, I can see the values that I want in my logs but my method always returns an empty arraylist. Kindly find my code below: public static ArrayList<Transaction> getUserTransactions(String userId){ Query userTransactionQuery = mDatabaseReference .child("transactions") .orderByChild("userId") .equalTo(userId); final ArrayList<Transaction> transactionsByUser = new ArrayList<>(); userTransactionQuery.addValueEventListener(new ValueEventListener(