mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
delete unique key from db
This commit is contained in:
@@ -209,6 +209,10 @@ $utopia->delete('/v1/users/:userId')
|
||||
throw new Exception('Failed to remove user from DB', 500);
|
||||
}
|
||||
|
||||
if (!$projectDB->deleteUniqueKey(md5('users:email='.$user->getAttribute('email', null)))) {
|
||||
throw new Exception('Failed to remove unique key from DB', 500);
|
||||
}
|
||||
|
||||
$reservedId = $projectDB->createDocument([
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RESERVED,
|
||||
'$id' => $userId,
|
||||
|
||||
@@ -88,6 +88,15 @@ abstract class Adapter
|
||||
*/
|
||||
abstract public function deleteDocument($id);
|
||||
|
||||
/**
|
||||
* Delete Unique Key.
|
||||
*
|
||||
* @param int $key
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract public function deleteUniqueKey($key);
|
||||
|
||||
/**
|
||||
* Create Namespace.
|
||||
*
|
||||
|
||||
@@ -191,7 +191,7 @@ class MySQL extends Adapter
|
||||
$st = $this->getPDO()->prepare('INSERT INTO `'.$this->getNamespace().'.database.unique`
|
||||
SET `key` = :key;
|
||||
');
|
||||
|
||||
|
||||
$st->bindValue(':key', \md5($data['$collection'].':'.$key.'='.$value), PDO::PARAM_STR);
|
||||
|
||||
if (!$st->execute()) {
|
||||
@@ -366,6 +366,26 @@ class MySQL extends Adapter
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Unique Key.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteUniqueKey($key)
|
||||
{
|
||||
$st1 = $this->getPDO()->prepare('DELETE FROM `'.$this->getNamespace().'.database.unique` WHERE `key` = :key');
|
||||
|
||||
$st1->bindValue(':key', $key, PDO::PARAM_STR);
|
||||
|
||||
$st1->execute();
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Relation.
|
||||
*
|
||||
|
||||
@@ -153,6 +153,22 @@ class Redis extends Adapter
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Unique Key.
|
||||
*
|
||||
* @param $key
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteUniqueKey($key)
|
||||
{
|
||||
$data = $this->adapter->deleteUniqueKey($key);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Namespace.
|
||||
*
|
||||
|
||||
@@ -298,6 +298,18 @@ class Database
|
||||
return new Document($this->adapter->deleteDocument($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $key
|
||||
*
|
||||
* @return Document|false
|
||||
*
|
||||
* @throws AuthorizationException
|
||||
*/
|
||||
public function deleteUniqueKey($key)
|
||||
{
|
||||
return new Document($this->adapter->deleteUniqueKey($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user