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.
Related
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.
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'});
How can I get the document id of a collection present in the cloud Firestore?
I tried to get it by using the
firebase.firestore().collection("collectionName").doc().id
but I didn't get the appropriate result.
firebase.firestore().collection("societies").doc().id and it returns a id which is not equivalent to society documentId
That's correct because everytime when you are using the above line of code, you are generating a new document id which will never be the same with one that already exist in your database.
In order to use a new document id, first you need to generate it (as you already do) and then store it in a variable. Having that varaible which holds that id, you can use it to get that particular document from the database by passing this id as an argument to the doc(id) function:
firebase.firestore().collection("societies").doc(this.myId)
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';
I am obtaining a json array from a url and inserting data into a table. Since the contents of the url are subject to change, I want to make a second connection to a url and check for updates and insert new records in y table using sqlite3.
The issues that I face are:
1) My table doesn't have a primary key
2) The url lists the changes on the same day. Hence, if I run my app multiple times, when I insert values in my database, I get duplicate entries. I want to keep a check for the day duplicated entries that should be removed. The problem can be solved by adding a constraint, but since the url itself has duplicated values, I find it difficult.
The only way I can see you can do it if you have no primary key or something you can use that is unique to each record, is when you get your new data in you go through the new entries where for each one you check if the exact same data exists in the database already. If it doesn't then you add it, if it does then you skip over it.
You could even do something like create a unique key yourself for each entry which is a concatenation of each column of the table. That way you can quickly do the check for if the entry already exists in the database.
I see two possibilities depending on your setup:
You have a column setup as UNIQUE (this can be through a PRIMARY KEY or not). In this case, you can use the ON CONFLICT clause:
http://www.sqlite.org/lang_conflict.html
If you find this construct a little confusing, you can instead use "INSERT OR REPLACE" or "INSERT OR IGNORE" as described here:
http://www.sqlite.org/lang_insert.html
You do not have a column setup as UNIQUE. In this case, you will need to SELECT first to verify for duplicate data, and based on the result INSERT, UPDATE, or do nothing.
A more common & robust way to handle this is to associate a timestamp with each data item on the server. When your app interrogates the server it provides the timestamp corresponding to the last time it synced. The server then queries its database and returns all values that are timestamped later than the timestamp provided by the app. Then it also returns a new timestamp value for the app to store, to use on the next sync.