Example #1
0
 /**
  * Create or update indexes, it needs to be called a least one time and when have some
  * operation that not use this lib. Index operation are executed in background.
  *
  * @param MongoCollection $collection
  * @param String $relType
  */
 public static function performIndexes(MongoCollection $collection, $relType)
 {
     $relType = strtolower($relType);
     $prefix = Instance::REL_PREFIX . $relType . '.';
     $collection->ensureIndex(['_id' => 1, $prefix . '_collection' => 1], ['background' => true]);
     // for incoming searches
     $collection->ensureIndex(['_id' => 1, $prefix . '_id' => 1, $prefix . '_collection' => 1], ['unique' => true, 'background' => true]);
     // for ensure integrity
 }