Example #1
0
 /**
  * {@inheritdoc}
  */
 public function hasTable($table)
 {
     try {
         if (!is_null($this->connection->openBucket($table)->getName())) {
             return true;
         }
     } catch (\CouchbaseException $e) {
         return false;
     }
 }
 public function testBlueprintSchemaBuildAndDropIndexes()
 {
     $schema = $this->connection->getSchemaBuilder();
     $schema->create('sample', function (\Ytake\LaravelCouchbase\Schema\Blueprint $blueprint) {
         $blueprint->primaryIndex();
         $blueprint->index(["message"], "secondary");
         $blueprint->dropPrimary();
         $blueprint->dropIndex("secondary");
     });
     $indexes = $this->connection->openBucket('sample')->manager()->listN1qlIndexes();
     foreach ($indexes as $index) {
         $this->assertNotSame('sample', $index->keyspace);
     }
     $this->removeBucket($this->connection->manager(), 'sample');
     sleep(5);
 }
 /**
  * generate increment key
  *
  * @param int $initial
  *
  * @return int
  */
 protected function incrementKey($initial = 1)
 {
     $result = $this->database->openBucket($this->table)->counter($this->identifier(), $initial, ['initial' => abs($initial)]);
     return $result->value;
 }
Example #4
0
 /**
  * Specify a secondary index for the current bucket.
  *
  * @param array   $columns            the JSON fields to index.
  * @param string  $name               the name of the index.
  * @param string  $whereClause        the WHERE clause of the index.
  * @param boolean $ignoreIfExist      if a secondary index already exists with that name, an exception will be
  *                                    thrown unless this is set to true.
  * @param boolean $defer              true to defer building of the index until buildN1qlDeferredIndexes() is
  *                                    called (or a direct call to the corresponding query service API).
  *
  * @return mixed
  */
 public function index($columns, $name = null, $whereClause = '', $ignoreIfExist = false, $defer = false)
 {
     $name = is_null($name) ? $this->getTable() . "_secondary_index" : $name;
     return $this->connection->openBucket($this->getTable())->manager()->createN1qlIndex($name, $columns, $whereClause, $ignoreIfExist, $defer);
 }