Import MongoDB ODM Project
This short tutorial demonstrates that in Skipper import of existing MongoDB ODM project and the following model editing is simple and intuitive.
Hint: See the ODM Model basics for detailed description of ODM elements (e.g. bundle, entity).
Import project
First, import sample MongoDB ODM project Bug Tracker or some of your existing projects. To do this select Import ODM Schema Files from File menu and follow the steps shown in the pictures below.









The last screen visually represents Bug Tracker project imported to Skipper and arranged automatically by import algorithm. It is a good starting point to work with your model.
Arrange visual model
Although imported model is automatically arranged it is a good idea to reposition entities inside the bundles to exactly fit the model logic. Also, you can change colors of bundles according to your preferences.


Extend project model
Now that you have a nice visual model we are going to show you how to extend Bug Tracker model to store attachments for Bug reports. We add Attachment entity, configure new fields and create association between Bug and Attachment entity.






Export model
Now with updated model it is time to export model back to MongoDB ODM schema definition files. Because model is imported from the existing schema files, export is automatically configured to export the data back to these files. Before the first export check that export locations and fODMats are correct.
Skipper exports single schema file for each MongoDB ODM entity. This means that our project will export five schema definition files, one for each entity in the model. Each bundle can have its own export fODMat and path which is relative to project root directory. For MongoDB ODM it is XML, YML and annotations.






And here is an example of the new Attachment entity. As you can see, everything is well formatted and exported in MongoDB ODM XML format.
<doctrine-mongo-mapping ...>
<document name="Entities\Attachment">
<field name="id" id="true" type="int"/>
<field name="caption" type="string"/>
<field name="description" type="string"/>
<field name="content" type="string"/>
<field name="bug_id" type="int"/>
<reference-one field="bug" target-document="Entities\Bug" inversed-by="attachment"/>
</document>
</doctrine-mongo-mapping>
Skipper can export schema definitions to all supported MongoDB ODM export formats - XML, YML or annotations. When you select annotations format export will look like this:
<?php
namespace Entities;
use Doctrine\ODM\MongoDB\Mapping\Annotations AS ODM;
/**
* @ODM\Document
*/
class Attachment
{
/**
* @ODM\Id(type="int")
*/
private $id;
/**
* @ODM\Field(type="string")
*/
private $caption;
/**
* @ODM\Field(type="string")
*/
private $description;
/**
* @ODM\Field(type="string")
*/
private $content;
/**
* @ODM\Field(type="int")
*/
private $bug_id;
/**
* @ODM\ReferenceOne(targetDocument="Entities\Bug", inversedBy="attachment")
*/
private $bug;
}
Next time you will need to make further changes or adjust the model, just open Skipper file and edit your project entities. Then again export the project to ORM.
Conclusion
As you can see above, import, editing and export to schema definition files is a five minute work with Skipper (ten if you are doing it for the first time). Now compare it with the effort of doing such task manually. As you have just discovered Skipper dramatically saves your time and helps you to work with schema definitions in much more enjoyable way.