mirror of
https://github.com/appwrite/appwrite
synced 2026-05-06 06:48:22 +00:00
Merge pull request #1462 from appwrite/feat-update-db-to-0.6
feat(refactor-db): update utopia-php/database to 0.6
This commit is contained in:
commit
314b8163cf
9 changed files with 38 additions and 38 deletions
|
|
@ -156,7 +156,7 @@ App::post('/v1/account/sessions')
|
|||
$email = \strtolower($email);
|
||||
$protocol = $request->getProtocol();
|
||||
|
||||
$profile = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [$email])], 1); // Get user by email address
|
||||
$profile = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [$email])]); // Get user by email address
|
||||
|
||||
if (!$profile || !Auth::passwordVerify($password, $profile->getAttribute('password'))) {
|
||||
$audits
|
||||
|
|
@ -442,16 +442,16 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
|||
}
|
||||
}
|
||||
|
||||
$user = ($user->isEmpty()) ? $dbForInternal->findFirst('sessions', [ // Get user by provider id
|
||||
$user = ($user->isEmpty()) ? $dbForInternal->findOne('sessions', [ // Get user by provider id
|
||||
new Query('provider', QUERY::TYPE_EQUAL, [$provider]),
|
||||
new Query('providerUid', QUERY::TYPE_EQUAL, [$oauth2ID]),
|
||||
], 1) : $user;
|
||||
]) : $user;
|
||||
|
||||
if ($user === false || $user->isEmpty()) { // No user logged in or with OAuth2 provider ID, create new one or connect with account with same email
|
||||
$name = $oauth2->getUserName($accessToken);
|
||||
$email = $oauth2->getUserEmail($accessToken);
|
||||
|
||||
$user = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [$email])], 1); // Get user by email address
|
||||
$user = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [$email])]); // Get user by email address
|
||||
|
||||
if ($user === false || $user->isEmpty()) { // Last option -> create the user, generate random password
|
||||
$limit = $project->getAttribute('usersAuthLimit', 0);
|
||||
|
|
@ -1074,7 +1074,7 @@ App::patch('/v1/account/email')
|
|||
}
|
||||
|
||||
$email = \strtolower($email);
|
||||
$profile = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [\strtolower($email)])], 1); // Get user by email address
|
||||
$profile = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [\strtolower($email)])]); // Get user by email address
|
||||
|
||||
if ($profile) {
|
||||
throw new Exception('User already registered', 400);
|
||||
|
|
@ -1379,7 +1379,7 @@ App::post('/v1/account/recovery')
|
|||
$isAppUser = Auth::isAppUser(Authorization::$roles);
|
||||
|
||||
$email = \strtolower($email);
|
||||
$profile = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [$email])], 1); // Get user by email address
|
||||
$profile = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [$email])]); // Get user by email address
|
||||
|
||||
if (!$profile) {
|
||||
throw new Exception('User not found', 404);
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ App::post('/v1/database/collections/:collectionId/attributes')
|
|||
$signed = true;
|
||||
$filters = [];
|
||||
|
||||
$success = $dbForExternal->addAttributeInQueue($collectionId, $id, $type, $size, $required, $default, $signed, $array, $filters);
|
||||
$success = $dbForExternal->addAttributeInQueue($collectionId, $id, $type, $size, $required, $default, $signed, $array, /*format*/ null, $filters);
|
||||
|
||||
// Database->addAttributeInQueue() does not return a document
|
||||
// So we need to create one for the response
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ App::post('/v1/teams/:teamId/memberships')
|
|||
throw new Exception('Team not found', 404);
|
||||
}
|
||||
|
||||
$invitee = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [$email])], 1); // Get user by email address
|
||||
$invitee = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [$email])]); // Get user by email address
|
||||
|
||||
if (empty($invitee)) { // Create new user if no user with same email found
|
||||
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ App::init(function ($utopia, $request, $response, $console, $project, $dbForCons
|
|||
} else {
|
||||
Authorization::disable();
|
||||
|
||||
$certificate = $dbForConsole->findFirst('certificates', [
|
||||
$certificate = $dbForConsole->findOne('certificates', [
|
||||
new Query('domain', QUERY::TYPE_EQUAL, [$domain->get()])
|
||||
], /*limit*/ 1);
|
||||
]);
|
||||
|
||||
if (empty($certificate)) {
|
||||
$certificate = new Document([
|
||||
|
|
|
|||
|
|
@ -78,9 +78,9 @@ class CertificatesV1 extends Worker
|
|||
}
|
||||
}
|
||||
|
||||
$certificate = $dbForConsole->findFirst('certificates', [
|
||||
$certificate = $dbForConsole->findOne('certificates', [
|
||||
new Query('domain', QUERY::TYPE_EQUAL, [$domain->get()])
|
||||
], /*limit*/ 1);
|
||||
]);
|
||||
|
||||
// $condition = ($certificate
|
||||
// && $certificate instanceof Document
|
||||
|
|
|
|||
|
|
@ -71,9 +71,10 @@ class DatabaseV1 extends Worker
|
|||
$default = $attribute->getAttribute('default', null);
|
||||
$signed = $attribute->getAttribute('signed', true);
|
||||
$array = $attribute->getAttribute('array', false);
|
||||
$format = $attribute->getAttribute('format', null);
|
||||
$filters = $attribute->getAttribute('filters', []);
|
||||
|
||||
$success = $dbForExternal->createAttribute($collectionId, $id, $type, $size, $required, $default, $signed, $array, $filters);
|
||||
$success = $dbForExternal->createAttribute($collectionId, $id, $type, $size, $required, $default, $signed, $array, $format, $filters);
|
||||
if ($success) {
|
||||
$removed = $dbForExternal->removeAttributeInQueue($collectionId, $id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
"utopia-php/cache": "0.4.*",
|
||||
"utopia-php/cli": "0.11.*",
|
||||
"utopia-php/config": "0.2.*",
|
||||
"utopia-php/database": "0.5.*",
|
||||
"utopia-php/database": "0.6.*",
|
||||
"utopia-php/locale": "0.3.*",
|
||||
"utopia-php/registry": "0.5.*",
|
||||
"utopia-php/preloader": "0.2.*",
|
||||
|
|
|
|||
45
composer.lock
generated
45
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "58102c809e5d82ce2c41dfca515a18dc",
|
||||
"content-hash": "0247f77dbdda25ccaeef2d9ae9671325",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
|
|
@ -1666,22 +1666,22 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/abuse",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/abuse.git",
|
||||
"reference": "f568f97467eca66450af6fba18038ddeb8e8d05a"
|
||||
"reference": "c9078aa3a87750d66060f0ed7642e03e5815da17"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/f568f97467eca66450af6fba18038ddeb8e8d05a",
|
||||
"reference": "f568f97467eca66450af6fba18038ddeb8e8d05a",
|
||||
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/c9078aa3a87750d66060f0ed7642e03e5815da17",
|
||||
"reference": "c9078aa3a87750d66060f0ed7642e03e5815da17",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-pdo": "*",
|
||||
"php": ">=7.4",
|
||||
"utopia-php/database": "0.5.*"
|
||||
"utopia-php/database": "0.6.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.4",
|
||||
|
|
@ -1713,9 +1713,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/abuse/issues",
|
||||
"source": "https://github.com/utopia-php/abuse/tree/0.6.0"
|
||||
"source": "https://github.com/utopia-php/abuse/tree/0.6.1"
|
||||
},
|
||||
"time": "2021-08-01T11:16:50+00:00"
|
||||
"time": "2021-08-03T19:31:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/analytics",
|
||||
|
|
@ -1774,22 +1774,22 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/audit",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/audit.git",
|
||||
"reference": "f81bbe0bf64d74c9668ca7ab90d0b6eb3df4d47e"
|
||||
"reference": "971dcd5c88309656df31ac20f326d3ac8b555594"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/audit/zipball/f81bbe0bf64d74c9668ca7ab90d0b6eb3df4d47e",
|
||||
"reference": "f81bbe0bf64d74c9668ca7ab90d0b6eb3df4d47e",
|
||||
"url": "https://api.github.com/repos/utopia-php/audit/zipball/971dcd5c88309656df31ac20f326d3ac8b555594",
|
||||
"reference": "971dcd5c88309656df31ac20f326d3ac8b555594",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-pdo": "*",
|
||||
"php": ">=7.4",
|
||||
"utopia-php/database": "0.5.*"
|
||||
"utopia-php/database": "0.6.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.3",
|
||||
|
|
@ -1821,9 +1821,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/audit/issues",
|
||||
"source": "https://github.com/utopia-php/audit/tree/0.6.0"
|
||||
"source": "https://github.com/utopia-php/audit/tree/0.6.1"
|
||||
},
|
||||
"time": "2021-08-01T11:14:31+00:00"
|
||||
"time": "2021-08-03T19:29:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/cache",
|
||||
|
|
@ -1984,16 +1984,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "0.5.0",
|
||||
"version": "0.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "e050e51060df72eff3af9fc24fc95a41ca9a2096"
|
||||
"reference": "561adc215fce3bd3b8c3ebb971ca354fb1526f26"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/e050e51060df72eff3af9fc24fc95a41ca9a2096",
|
||||
"reference": "e050e51060df72eff3af9fc24fc95a41ca9a2096",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/561adc215fce3bd3b8c3ebb971ca354fb1526f26",
|
||||
"reference": "561adc215fce3bd3b8c3ebb971ca354fb1526f26",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -2041,9 +2041,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/0.5.0"
|
||||
"source": "https://github.com/utopia-php/database/tree/0.6.0"
|
||||
},
|
||||
"time": "2021-07-03T16:49:44+00:00"
|
||||
"time": "2021-08-03T15:13:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/domains",
|
||||
|
|
@ -5154,7 +5154,6 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"abandoned": true,
|
||||
"time": "2020-09-28T06:45:17+00:00"
|
||||
},
|
||||
{
|
||||
|
|
@ -6279,5 +6278,5 @@
|
|||
"platform-overrides": {
|
||||
"php": "8.0"
|
||||
},
|
||||
"plugin-api-version": "2.0.0"
|
||||
"plugin-api-version": "2.1.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class WebhooksCustomServerTest extends Scope
|
|||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'id' => 'fullname',
|
||||
'type' => 'text',
|
||||
'type' => 'key',
|
||||
'attributes' => ['lastName', 'firstName'],
|
||||
'orders' => ['ASC', 'ASC'],
|
||||
]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue