Skip to content

Commit f0a9d05

Browse files
committed
linter
1 parent 4ecc004 commit f0a9d05

1 file changed

Lines changed: 18 additions & 19 deletions

File tree

src/Database/Adapter/Mongo.php

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Utopia\Database\DateTime;
1212
use Utopia\Database\Document;
1313
use Utopia\Database\Exception as DatabaseException;
14-
use Utopia\Database\Exception\Duplicate as DuplicateException;
1514
use Utopia\Database\Exception\Duplicate;
1615
use Utopia\Database\Exception\Timeout;
1716
use Utopia\Database\Query;
@@ -727,7 +726,7 @@ public function getDocument(string $collection, string $id, array $queries = [],
727726
}
728727

729728
$result = $this->client->find($name, $filters, $options)->cursor->firstBatch;
730-
729+
731730
if (empty($result)) {
732731
return new Document([]);
733732
}
@@ -857,7 +856,7 @@ private function insertDocument(string $name, array $document): array
857856
$filters,
858857
['limit' => 1]
859858
)->cursor->firstBatch[0];
860-
859+
861860
return $this->client->toArray($result);
862861
} catch (MongoException $e) {
863862
throw new Duplicate($e->getMessage());
@@ -953,7 +952,7 @@ public function createOrUpdateDocuments(string $collection, string $attribute, a
953952
if (empty($changes)) {
954953
return $changes;
955954
}
956-
955+
957956
try {
958957
$name = $this->getNamespace() . '_' . $this->filter($collection);
959958
$attribute = $this->filter($attribute);
@@ -970,7 +969,7 @@ public function createOrUpdateDocuments(string $collection, string $attribute, a
970969
$attributes['_createdAt'] = $document->getCreatedAt();
971970
$attributes['_updatedAt'] = $document->getUpdatedAt();
972971
$attributes['_permissions'] = $document->getPermissions();
973-
972+
974973
if (!empty($document->getSequence())) {
975974
$attributes['_id'] = new ObjectId($document->getSequence());
976975
} else {
@@ -985,7 +984,7 @@ public function createOrUpdateDocuments(string $collection, string $attribute, a
985984
$record = $this->replaceChars('$', '_', $attributes);
986985
$record = $this->timeToMongo($record);
987986
$record = $this->removeNullKeys($record);
988-
987+
989988

990989
// Build filter for upsert
991990
$filter = ['_uid' => $document->getId()];
@@ -1009,19 +1008,19 @@ public function createOrUpdateDocuments(string $collection, string $attribute, a
10091008
'filter' => $filter,
10101009
'update' => $update,
10111010
];
1012-
}
1013-
1011+
}
1012+
10141013
// Use the new bulkUpsert method
10151014
$this->client->bulkUpsert(
10161015
$name,
10171016
$operations,
1018-
["ordered" => false] // TODO Do we want to continue if an error is thrown?
1017+
["ordered" => false] // TODO Do we want to continue if an error is thrown?
10191018
);
10201019

10211020
// Get sequences for documents that were created
10221021
if (!empty($documentIds)) {
10231022
$sequences = $this->getSequences($collection, $documentIds, $documentTenants);
1024-
1023+
10251024
foreach ($changes as $change) {
10261025
if (isset($sequences[$change->getNew()->getId()])) {
10271026
$change->getNew()->setAttribute('$sequence', $sequences[$change->getNew()->getId()]);
@@ -1032,7 +1031,7 @@ public function createOrUpdateDocuments(string $collection, string $attribute, a
10321031
} catch (MongoException $e) {
10331032
throw $this->processException($e);
10341033
}
1035-
1034+
10361035
return \array_map(fn ($change) => $change->getNew(), $changes);
10371036
}
10381037

@@ -1061,7 +1060,7 @@ protected function getSequences(string $collection, array $documentIds, array $d
10611060

10621061
try {
10631062
$results = $this->client->find($name, $filters, ['projection' => ['_uid' => 1, '_id' => 1]]);
1064-
1063+
10651064
foreach ($results->cursor->firstBatch as $result) {
10661065
$sequences[$result->_uid] = (string)$result->_id;
10671066
}
@@ -1249,7 +1248,7 @@ public function find(string $collection, array $queries = [], ?int $limit = 25,
12491248
if ($this->sharedTables) {
12501249
$filters['_tenant'] = $this->getTenant();
12511250
}
1252-
1251+
12531252
// permissions
12541253
if (Authorization::$status) {
12551254
$roles = \implode('|', Authorization::getRoles());
@@ -1306,7 +1305,7 @@ public function find(string $collection, array $queries = [], ?int $limit = 25,
13061305
$prevAttr = $this->filter($this->getInternalKeyForAttribute($originalPrev));
13071306

13081307
$tmp = $cursor[$originalPrev];
1309-
if($originalPrev === '$sequence'){
1308+
if ($originalPrev === '$sequence') {
13101309
$tmp = new ObjectId($tmp);
13111310
}
13121311

@@ -1317,11 +1316,11 @@ public function find(string $collection, array $queries = [], ?int $limit = 25,
13171316

13181317
$tmp = $cursor[$originalAttribute];
13191318

1320-
if($originalAttribute === '$sequence'){
1319+
if ($originalAttribute === '$sequence') {
13211320
$tmp = new ObjectId($tmp);
13221321

13231322
/** If there is only $sequence attribute in $orderAttributes skip Or And operators **/
1324-
if(count($orderAttributes) === 1){
1323+
if (count($orderAttributes) === 1) {
13251324
$filters[$attribute] = [
13261325
$operator => $tmp
13271326
];
@@ -1356,16 +1355,16 @@ public function find(string $collection, array $queries = [], ?int $limit = 25,
13561355
} catch (MongoException $e) {
13571356
throw $this->processException($e);
13581357
}
1359-
1358+
13601359

13611360
if (empty($results)) {
13621361
return $found;
13631362
}
1364-
1363+
13651364

13661365
foreach ($this->client->toArray($results) as $result) {
13671366
$record = $this->replaceChars('_', '$', (array)$result);
1368-
1367+
13691368
$record = $this->timeToDocument($record);
13701369

13711370
$found[] = new Document($record);

0 commit comments

Comments
 (0)