/** * @param string $name Index name * @param array $fields Index fields, ex: title (ascending), -title (descending), title => 'text' * @param bool $sparse Is index sparse? * @param bool $unique Is index unique? * @param bool $dropDuplicates Drop duplicate documents (only if $unique is used) * * @throws MongoException */ public function __construct($name, array $fields, $sparse = false, $unique = false, $dropDuplicates = false) { if (count($fields) < 2) { throw new MongoException(MongoException::COMPOUND_INDEX_NOT_ENOUGH_FIELDS); } parent::__construct($name, $fields, $sparse, $unique, $dropDuplicates); }
/** * @param string $name Index name * @param string $field Index field * * @throws \Webiny\Component\Mongo\MongoException */ public function __construct($name, $field) { if (!is_string($field)) { throw new MongoException('Index field must be a string'); } parent::__construct($name, [$field => '2dsphere']); }
public function getOptions() { $options = parent::getOptions(); if ($this->isNumber($this->ttl)) { $options['expireAfterSeconds'] = $this->ttl; } return $options; }
public function getOptions() { $options = parent::getOptions(); $options['default_language'] = $this->language; return $options; }