Firebase value not being deleted - ios

I tried to delete one child from Firebase, however, it is not removing it for some reason.
This is how I tied to delete it(I get the right reference):
FIRDatabase.database().reference().child("posts").child(commentsArray[indexPath.row].key).removeValue()
If I try to po this value the output is e.g:
https://snuspedia.firebaseio.com/posts/coments/-KTzfD1wOa9sRXw93gAF
Which is this:
Am I doing something wrong?

So what I recognize is that you miss the key of the post:
https://snuspedia.firebaseio.com/posts/<KEY OF YOUR POST>/comments/-KTzfD1wOa9sRXw93gAF
Reference code should include the key of the specific post:
FIRDatabase.database().reference().child("posts").child(<KEY OF YOUR POST>).child("comments").child(commentsArray[indexPath.row].key).removeValue()

Related

MagicalRecord throws relatedByAttribute error

I have an strange error in my log and I am not sure what I need to check.
Invalid value for key 'relatedByAttribute' in 'WorkoutEntity' entity. Remove this key or add attribute
This is one place what I found where I use relatedByAttribute in WorkoutEntity
Do you have an idea what can I check as well to see issue.
I had the same problem. In my case, I opened the .xcdatamodeld with an external editor, looked for the "relatedByAttribute" label and found that the label was "relatedByAttribute " instead (note the blank space).
Removed the blank and worked since then.
I hope it's good for you! ;)

Is it possible to unlink a linked record using the Relay Modern imperative mutation API?

I would like write a mutation updater that unlinks a linked record from another record.
For example, suppose I have the following in my store:
client:root {
user: {__ref: "someid"}
}
I am looking for a way to unlink user and client:root. user is a nullable field. I would like subscribers that are interested in the user field to see it has gone null.
Right now the only way I am seeing to unlink this field is to delete the node from the store. I've tried setting the link to null using setLinkedRecord but that throws an error.
.setLinkedRecored() expects the first argument to be an instance of RecordProxy. Use .setValue() for unlinking nodes, as whitep4nther commented above.
store.getRoot().setValue(undefined, 'user');
I was just fighting with this as well, and after digging through the relay codebase, I decided there isn't an appropriate way to go about this right now. I've opened an issue here.

SetValue in Swift from Firebase removes old value's

In the documentation it says that I should use this code to set new value's:
self.ref.child("users").child(user.uid).setValue(["username": username])
This way, I can set an username. However, if I want to add another value later on, like XP points, I use the following line of code:
var XPPoints = 1
self.ref.child("users").child(user.uid).setValue(["XPPoints": XPPoints])
This, however, deletes the username value, or any other value that was stored before. It replaces all value's.
I tried also the second thing the docs are saying at: https://firebase.google.com/docs/database/ios/read-and-write#basic_write which is this line of code:
self.ref.child("users/(user.uid)/username").setValue(username)
This will crash my app instantly when starting up. My question is: How can I add data, and not replacing the old value's?
Edit:
Fixed it by changing the code to:
self.ref.child("users/\(user.uid)/username").setValue(username)
Your solution shouldn't fix the problem you are having. You need to use updateChildValues instead of setValue. This adds the values instead of overwriting everything in the referenced node.

Symfony: Save multiple same objects

I have a page that shows 3 Objects (they are the same class).
I want to save them.
Unfortunaly only the latest one gets updated. All other seems to be invalid.
So my idea was to give them unique names: testObject_1[text1], testObject_2[text1].
This works as I can see it in the source code.
But how can I pass this name to form->save() in order to get the POST-reply filtered by this name (testObject_1) and then save it?
Or is there something more easier?
Thank you
Tobias Kaminsky
I solved it:
$temp->bind($request->getParameter("testObject_$i"), $request->getFiles("testObject_$i"));
(where $i is an Index stored in the database)

Site column does not get deleted

I have a Site column which i delete programatically using the following code. I have already removed all references to the field previously. However, even if there is not error, it goes to fieldtodelete.Delete() and steps through the next line. However, when i check the Site Column collection using SPM2007 or via the UI the site column is still there.
Dim fieldtodelete As SPField
Try
fieldtodelete = site.RootWeb.Fields.GetFieldByInternalName(name)
'site.RootWeb.Fields.GetFieldByInternalName(name)
fieldtodelete.Delete()
Catch ex As Exception
Console.WriteLine("Field: {0} was not deleted", name)
Return 0
End Try
Any ideas on why sharepoint does this? Also, there are 2 fields with the same name, i am not sure if this has a direct effect on this. I want to delete both.
Thanks
Since there are 2 fields with the same name, their internal names are likely different than the Name. Are you sure the line
fieldtodelete = site.RootWeb.Fields.GetFieldByInternalName(name)
is actually returning a valid SPField? If not, you will need to find the internal names of the fields, which don't necessarily match up to the Names.
EDIT: Since you said that you are getting the fields back, I realized you aren't calling site.RootWeb.Update() after deleting the field. That should fix the issue.

Resources