I have added and updated fields in a collection, but it doesn’t apply to previously entered collections.
Is there a way to update the previously entered collection to have the new field?
I have added and updated fields in a collection, but it doesn’t apply to previously entered collections.
Is there a way to update the previously entered collection to have the new field?
Because the collection entry is being stored as a JSON object, an empty field is not created on previous entries as you would expect if the data was stored in a relational database. If you update a previous entry, even if you make no changes to the entry, it will insert that new field name into the JSON data for that entry.
The same goes, unfortunately, for deleting a field…
If you have two fields called first_name and last_name and you have data for both fields, should you remove last_name the data will persist once the field is deleted—even if you re-save the entry. It will also show up within the returned JSON for the API. You can theoretically never delete old data from deleted fields unless you manually edit each entry and remove it prior to removing a field.
This is particularly shitty with sensitive information. In this example, I removed the Password field, yet the data persists in the JSON.
{ "Name": "John", "Password": "$2y$10$bw7QkIC54GiJ2YBnyt7RfetyYOEfoc6l6NgqmGcWL/jU3A.eKx92W", "_mby": "5ff51af63038362abb0002dd", "_by": "5ff51af63038362abb0002dd", "_modified": 1609906512, "_created": 1609906443, "_id": "5ff5390b33613138d300032b" }
Additionally, the data is stored in the revisions:
{ "_oid": "5ff5390b33613138d300032b", "data": { "Name": "John", "Password": "$2y$10$bLlmnDN7tnc1U7JK5KzZL.I0M\/xZFR0RrHKPZF6x0lMXjzEhshTgG", "_mby": "5ff51af63038362abb0002dd", "_by": "5ff51af63038362abb0002dd", "_modified": 1609906443, "_created": 1609906443, "_id": "5ff5390b33613138d300032b" }, "meta": "collections\/example", "_creator": "5ff51af63038362abb0002dd", "_created": 1609906443.418798, "_id": "5ff5390b333338345e00028b" }
In a lot of cases, you would want this information preserved. But I think there should be options for removing this data… maybe an addon could be created.
@tophermurphy @pixelkarma See my answer in this thread:
Well, perhaps this feature should have a toggle switch, in the config, to automatically remove the data when a field is removed. I’m trying to think of an situation where a developer would want data from a deleted field to show in the API. Especially if that field was once protected by permissions—it’s now open for everyone.
I think your comments here were on the right track.