I’ve got a collection loading from Firebase with a lot of columns. Whenever I refresh, the order in which those show up on Studio’s Data tab looks random at first. They’re not in alphabetical order, nor the order I originally created them. The stranger thing is that if I rearrange the columns in Studio, then refresh the data again, they go back to the seemingly-random order they had when I first loaded them. There seems to be some hidden heuristic at work for how they should be ordered.
Mind if I bump this one? I’m working with sheets with a whole lot of values, and searching for them on the Data tab is a pain.
I usually don’t feel confident enough to answer a question because I am not an expert at all but maybe I can be of help.
Collections in Firebase are ordered in alphabetical order according to the document_key which may look random if you have it set up to have an aleatory one when you create the document.
In order to have your collection ordered you can do it in the query field adding .orderBy([nameOfTheField]). I recommend you have a value in your documents like “createdAt” or “date” where you establish the creationDate so you can query and order according to that.
Depending on your project, you can also determine the documentKey for the documents. I like to assign them names that I can easily identify instead of using the random name Firestore gives them.
Finally, RS have a 20 rows limit to show your data from Firestore and it is not intended to use it directly to manage your database. You should create a CRUD personalized screen to manage your database.
I hope I can be of help
Oh sweet! I’ll give that a try. Thanks!
Hi, currently the Data sheet column order in the Studio is reset every time when one loads data via plugin. This is annoying and we’re looking for solution which would at least force the columns in alphabetical order even if the plugin code does not do that.
I’m supposed to paste “.orderBy([nameOfTheField])” into the Query field, correct? In related news, I’m also having an issue with getting the Firebase Plugin to work at this moment, so that could be complicating things as well. Thanks, all.
You have to set the name of the value you want to orderBy inside the parenthesis. In order to do that, you must have a field or value in all of your documents with the same name. For example, I specify the creation date for my documents with a field that is called “date” and the value is a number where I establish a number that represents the creation date and time.
Once you have that, I write in that query box “orderBy(‘date’, ‘desc’). You will probably receive a message that you need to create an index. Just follow the given link and accept to create that index. A few minutes after you will be able to get the ordered documents.
Aha! Yeah, that makes sense to sort the rows of my data sheet, for sure. The challenge I’m having is that every time I load a sheet into RS, the system scrambles the columns, to say nothing for the rows. I’m dealing with documents with dozens of fields, so having to search around for just the right value amidst all these scrambled columns is a drag.
Just a heads up that the latest update fixes the column ordering and manually sorted columns should now keep the ordering when you reload data via Plugin.