1
0
Fork 0
mirror of synced 2024-05-17 11:12:41 +12:00
appwrite/src/Appwrite/Database/Adapter.php

161 lines
2.8 KiB
PHP
Raw Normal View History

2019-05-09 18:54:39 +12:00
<?php
namespace Appwrite\Database;
2019-05-09 18:54:39 +12:00
use Exception;
abstract class Adapter
{
/**
* @var string
*/
protected $namespace = '';
/**
* Set Namespace.
2019-05-09 18:54:39 +12:00
*
* Set namespace to divide different scope of data sets
*
* @param $namespace
*
2019-05-09 18:54:39 +12:00
* @throws Exception
*
2019-05-09 18:54:39 +12:00
* @return bool
*/
public function setNamespace($namespace)
{
if (empty($namespace)) {
2019-05-09 18:54:39 +12:00
throw new Exception('Missing namespace');
}
$this->namespace = $namespace;
return true;
}
/**
* Get Namespace.
2019-05-09 18:54:39 +12:00
*
* Get namespace of current set scope
*
* @throws Exception
*
2019-05-09 18:54:39 +12:00
* @return string
*/
public function getNamespace()
{
if (empty($this->namespace)) {
2019-05-09 18:54:39 +12:00
throw new Exception('Missing namespace');
}
return $this->namespace;
}
/**
* Get Document.
2019-05-09 18:54:39 +12:00
*
* @param string $id
*
2019-05-09 18:54:39 +12:00
* @return array
*/
abstract public function getDocument($id);
/**
* Create Document
**.
*
2019-05-09 18:54:39 +12:00
* @param array $data
*
2019-05-09 18:54:39 +12:00
* @return array
*/
2020-07-26 23:21:58 +12:00
abstract public function createDocument(array $data = [], array $unique = []);
2019-05-09 18:54:39 +12:00
/**
* Update Document.
2019-05-09 18:54:39 +12:00
*
* @param array $data
*
2019-05-09 18:54:39 +12:00
* @return array
*/
2020-07-26 23:21:58 +12:00
abstract public function updateDocument(array $data = []);
2019-05-09 18:54:39 +12:00
/**
* Delete Node.
2019-05-09 18:54:39 +12:00
*
* @param string $id
*
2019-05-09 18:54:39 +12:00
* @return array
*/
abstract public function deleteDocument(string $id);
2019-05-09 18:54:39 +12:00
2020-08-29 06:53:19 +12:00
/**
* Delete Unique Key.
*
2021-06-24 02:02:24 +12:00
* @param string $key
2020-08-29 06:53:19 +12:00
*
* @return array
*/
abstract public function deleteUniqueKey($key);
/**
* Add Unique Key.
*
2021-06-24 02:02:24 +12:00
* @param string $key
*
* @return array
*/
abstract public function addUniqueKey($key);
2019-05-09 18:54:39 +12:00
/**
* Create Namespace.
2019-05-09 18:54:39 +12:00
*
* @param string $namespace
*
2019-05-09 18:54:39 +12:00
* @return bool
*/
abstract public function createNamespace($namespace);
2019-08-23 08:53:50 +12:00
/**
* Delete Namespace.
2019-08-23 08:53:50 +12:00
*
* @param string $namespace
*
2019-08-23 08:53:50 +12:00
* @return bool
*/
abstract public function deleteNamespace($namespace);
2019-05-09 18:54:39 +12:00
/**
* Filter.
2019-05-09 18:54:39 +12:00
*
* Filter data sets using chosen queries
*
* @param array $options
*
2019-05-09 18:54:39 +12:00
* @return array
*/
abstract public function getCollection(array $options);
/**
* @param array $options
*
2019-05-09 18:54:39 +12:00
* @return int
*/
abstract public function getCount(array $options);
/**
* Last Modified.
2019-05-09 18:54:39 +12:00
*
2020-06-24 23:18:33 +12:00
* Return Unix timestamp of last time a node queried in corrent session has been changed
2019-05-09 18:54:39 +12:00
*
* @return int
*/
abstract public function lastModified();
/**
* Get Debug Data.
2019-05-09 18:54:39 +12:00
*
* @return array
*/
abstract public function getDebug();
}