coen-hyde/Shanty-Mongo — Issue #42: Replacing complete DocumentSet
Author: tholder
Created: 2011-10-09 16:16:57+00:00
State: open

It's not very clear how you go about clearing and re-setting a documentset on an existing document.

Scenario is I have a document that has a documentset of categories. Each time I update the document I want to completely replace this field with the newly selected options. The only way I have found to successfully do this (every other way seems to just add the document) is to do the following:

$doc->name = $this->_getParam('name');
$doc->category = new Shanty_Mongo_DocumentSet();
$doc->category->addDocument($cat1);
$doc->category->addDocument($cat2);
$doc->save();

If this is the correct procedure I will add something to the wiki but is it worth putting a clearAll() method or something on to the DocumentSet object?