Sign In Register

How can we help you today?

Start a new topic
Answered

Partial Deletes?

I'm storing some data using the example described in Partial Updates:


https://docs.gamesparks.net/howtos/cloud-data/partial-updates


I would like to add the ability to delete. How would one go about this? 


Thanks,

Mike



Best Answer

Hi Mike,


For deleting specific fields in a document you can use the $unset parameter.


collection.update(

  {"id": Spark.getPlayer().playerId}, 

  {"$unset" : {<field>:""}}, 

  false,

  false

);


You can create a Cloud Code Script that passes the field into this to delete particular fields from a document. 


-Pádraig


Answer

Hi Mike,


For deleting specific fields in a document you can use the $unset parameter.


collection.update(

  {"id": Spark.getPlayer().playerId}, 

  {"$unset" : {<field>:""}}, 

  false,

  false

);


You can create a Cloud Code Script that passes the field into this to delete particular fields from a document. 


-Pádraig

OK, thanks. That works.

Login to post a comment