In a collection I have a string field that can be null some times. But, If that field has a value, it should be unique.I have tried like this,
/** @ODM\Field(type="string", nullable=true) @ODM\UniqueIndex(order="asc") */
private $empId;
I am using mongodb 3.0 ,doctrine 2 ORM on Zend Framework 2
Anyone know something on how to do that or if it's possible ?