1
0
Fork 0
mirror of synced 2024-06-02 19:04:49 +12:00

Adding Internal Ids to Database Api

This commit is contained in:
fogelito 2022-06-15 15:57:06 +03:00
parent fce6f152e8
commit 44e3851f5e
2 changed files with 41 additions and 2 deletions

View file

@ -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],
],
],
],

View file

@ -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,