Inheritance: implements Webiny\Component\Mongo\Index\IndexInterface, use trait Webiny\Component\StdLib\StdLibTrait
コード例 #1
0
ファイル: CompoundIndex.php プロジェクト: Webiny/Framework
 /**
  * @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);
 }
コード例 #2
0
ファイル: SphereIndex.php プロジェクト: Webiny/Framework
 /**
  * @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']);
 }
コード例 #3
0
ファイル: SingleIndex.php プロジェクト: Webiny/Framework
 public function getOptions()
 {
     $options = parent::getOptions();
     if ($this->isNumber($this->ttl)) {
         $options['expireAfterSeconds'] = $this->ttl;
     }
     return $options;
 }
コード例 #4
0
ファイル: TextIndex.php プロジェクト: Webiny/Framework
 public function getOptions()
 {
     $options = parent::getOptions();
     $options['default_language'] = $this->language;
     return $options;
 }