Merge pull request #3383 from appwrite/feat-internal-ids-collections
Feat internal ids Database Api
This commit is contained in:
commit
cf3de6d7ef
|
@ -119,6 +119,17 @@ $collections = [
|
|||
'$id' => 'attributes',
|
||||
'name' => 'Attributes',
|
||||
'attributes' => [
|
||||
[
|
||||
'$id' => 'collectionInternalId',
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
'signed' => true,
|
||||
'required' => false,
|
||||
'default' => null,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'collectionId',
|
||||
'type' => Database::VAR_STRING,
|
||||
|
@ -248,6 +259,13 @@ $collections = [
|
|||
],
|
||||
],
|
||||
'indexes' => [
|
||||
[
|
||||
'$id' => '_key_collection_internal_id',
|
||||
'type' => Database::INDEX_KEY,
|
||||
'attributes' => ['collectionInternalId'],
|
||||
'lengths' => [Database::LENGTH_KEY],
|
||||
'orders' => [Database::ORDER_ASC],
|
||||
],
|
||||
[
|
||||
'$id' => '_key_collection',
|
||||
'type' => Database::INDEX_KEY,
|
||||
|
@ -263,6 +281,17 @@ $collections = [
|
|||
'$id' => 'indexes',
|
||||
'name' => 'Indexes',
|
||||
'attributes' => [
|
||||
[
|
||||
'$id' => 'collectionInternalId',
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
'signed' => true,
|
||||
'required' => false,
|
||||
'default' => null,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'collectionId',
|
||||
'type' => Database::VAR_STRING,
|
||||
|
@ -349,6 +378,13 @@ $collections = [
|
|||
'lengths' => [Database::LENGTH_KEY],
|
||||
'orders' => [Database::ORDER_ASC],
|
||||
],
|
||||
[
|
||||
'$id' => '_key_collection_internal_id',
|
||||
'type' => Database::INDEX_KEY,
|
||||
'attributes' => ['collectionInternalId'],
|
||||
'lengths' => [Database::LENGTH_KEY],
|
||||
'orders' => [Database::ORDER_ASC],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ use MaxMind\Db\Reader;
|
|||
*
|
||||
*
|
||||
* @return Document Newly created attribute document
|
||||
* @throws Exception
|
||||
*/
|
||||
function createAttribute(string $collectionId, Document $attribute, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Event $events, Stats $usage): Document
|
||||
{
|
||||
|
@ -86,6 +87,7 @@ function createAttribute(string $collectionId, Document $attribute, Response $re
|
|||
$attribute = new Document([
|
||||
'$id' => $collectionId . '_' . $key,
|
||||
'key' => $key,
|
||||
'collectionInternalId' => $collection->getInternalId(),
|
||||
'collectionId' => $collectionId,
|
||||
'type' => $type,
|
||||
'status' => 'processing', // processing, available, failed, deleting, stuck
|
||||
|
@ -1263,8 +1265,8 @@ App::post('/v1/database/collections/:collectionId/indexes')
|
|||
}
|
||||
|
||||
$count = $dbForProject->count('indexes', [
|
||||
new Query('collectionId', Query::TYPE_EQUAL, [$collectionId])
|
||||
], 61);
|
||||
new Query('collectionInternalId', Query::TYPE_EQUAL, [$collection->getInternalId()])
|
||||
]);
|
||||
|
||||
$limit = 64 - MariaDB::getNumberOfDefaultIndexes();
|
||||
|
||||
|
@ -1304,6 +1306,7 @@ App::post('/v1/database/collections/:collectionId/indexes')
|
|||
'$id' => $collectionId . '_' . $key,
|
||||
'key' => $key,
|
||||
'status' => 'processing', // processing, available, failed, deleting, stuck
|
||||
'collectionInternalId' => $collection->getInternalId(),
|
||||
'collectionId' => $collectionId,
|
||||
'type' => $type,
|
||||
'attributes' => $attributes,
|
||||
|
|
|
@ -256,7 +256,7 @@ Database::addFilter(
|
|||
function (mixed $value, Document $document, Database $database) {
|
||||
return $database
|
||||
->find('attributes', [
|
||||
new Query('collectionId', Query::TYPE_EQUAL, [$document->getId()])
|
||||
new Query('collectionInternalId', Query::TYPE_EQUAL, [$document->getInternalId()])
|
||||
], $database->getAttributeLimit());
|
||||
}
|
||||
);
|
||||
|
@ -269,7 +269,7 @@ Database::addFilter(
|
|||
function (mixed $value, Document $document, Database $database) {
|
||||
return $database
|
||||
->find('indexes', [
|
||||
new Query('collectionId', Query::TYPE_EQUAL, [$document->getId()])
|
||||
new Query('collectionInternalId', Query::TYPE_EQUAL, [$document->getInternalId()])
|
||||
], 64);
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue