How to change a specific value for all firebase keys - flutter

I am making a flutter application. How do I retrieve and change the "Weight" value for all the keys in my Firebase database even if I do not know the names of all the keys?

You could use,
_ref!.child("childName").update({'MapValue': 'Value'});

Related

Firestore update map keys

Is it possible to update Firestore map's keys? I'm trying to do so through the Firestore dashboard and the key field is disabled as can be seen in the screenshot below? Does that mean that instead of updating the key, one needs to first delete the old entry and then create a new one?
There is no way to change the name of a field in Firestore. The API doesn't have such an operation, and (for that reason) it also isn't in the Firebase console.
You'll have to add a new field with the same value, and delete the old field.

Get Firebase Auto-ID column in FlutterFlow

Reviewing one of my Firebase schemas I can see that I have a couple of columns, but the auto-generated ID column does not show up:
However, when clicking on "Manage Content" the ID column can be seen:
The problem I have is that in other collections I make a reference to this collection by this ID, however, it doesn't pop-up in FlutterFlow to filter on:
Question: Is it possible to get the Auto-ID column in FlutterFlow?
As far as I know that is unfortunately not possible.
You could solve this by adding a column CopyOfId to your scheme.
You could then write a Firebase Function that triggers when you create a new document (https://firebase.google.com/docs/reference/functions/firebase-functions.firestore.documentbuilder.md?authuser=0#firestoredocumentbuilderoncreate). You could make this function copy the contents of the ID column to your own CopyOfId, making it accessible in FlutterFlow.
A deeper question is maybe for what use case you want this behaviour: why would you need to filter on an autogenerated ID that you do not know the value of - and that you can't access - in FlutterFlow? If we know your use case, there is probably another way to achieve what you want to achieve.

how to filter Collection (Firebase) by uid in swift

I'm having problems trying to get one specific value from Firebase.
I'm using .whereField('uid', isEqualsTo: "givenID") in Collection("something") but I'm not getting any response. I know in Flutter the field is 'uid' but for some reason in swift isn't the same. I'll appreciate your help maybe with the name of the field or another way to bring the value with the given id in Firebase.
Useful information
Swift 5
XCODE 11.4.1
I found a "solution". Create a field in my Collection called "id" and assigning it with the same id from the document. Now I can just
db.collection("yourCollection").whereField("id", isEqualsTo: "givenID").
Not the best solution, but a solution is a solution.
UPDATE
I found it.
db.Collection("yourCollection").document("GivenID")
This bright you the subCollection
And that's all

How to set more than one value to a child in Firebase using Swift?

I am trying to make a money related app which shows the user their spendings as a project to get used to Firebase. So I stumbled upon this issue; I can't seem to figure out how to add more than one expense assigned to a user. Whenever I add a new expense, the existing value in Firebase gets reset to the new value but I want it to store both the new and the old value. How can I do this?
There's something called "autoID" if that helps. I'll link that in a few moments.
Edit: It's used here.
childByAutoId() is what you want for swift. See Updating Or Deleting specific data section in the Read and Write Data on iOS
let thisUserRef = ref.child("users").child(users uid)
let expenseRef = thisUserRef.child("expenses").childByAutoId()
let dict = ["expense_type": "travel", "expense_amt": "1.99"]
expenseRef.setValue(dict)
will results in
users
uid_0
-Y88jn90skda //<- the node key created with childByAutoId
expense_type: "travel"
expense_amt: "1.99"
the childByAutoId is super powerful and allows 'random' node keys to be generated that contain your child data.
See the answer to this question and this other question for some tips on data modeling and queries.

Change the name of an item in a custom field using API

I am looking for a way to change the names of the items in a custom field I created in studio, without changing their display labels.
I used the field editor (still in studio) to change the associations between names and labels, but despite my modifications, I am still getting the former names (those that were defined before my modifications) when I'm using the API.
How can I make the new names be effective?
Thank you for your help.
When you change the keys in a dropdown list (you called them 'names'), it will change the language file in SugarCRM, but will not change the existing values in your database. So a query to existing records that used the old keys will still return those old key values.
You will need to perform UPDATE queries in your database similar to:
UPDATE contacts_cstm SET mydropdownvalue_c='NewValue' where mydropdownvalue_c = 'OldValue';