1
0
Fork 0
mirror of synced 2024-06-01 18:39:57 +12:00

Updated create collection

This commit is contained in:
Eldad Fux 2021-07-04 15:05:46 +03:00
parent 10202b2a30
commit c3cd9637f6
2 changed files with 48 additions and 44 deletions

View file

@ -96,38 +96,39 @@ App::post('/v1/projects')
$dbForExternal->setNamespace('project_' . $project->getId() . '_external');
$dbForExternal->create();
$audit = new Audit($dbForInternal);
$audit = new Audit($dbForConsole);
$audit->setup();
$adapter = new TimeLimit("", 0, 1, $dbForInternal);
$adapter = new TimeLimit("", 0, 1, $dbForConsole);
$adapter->setup();
foreach ($collections as $key => $collection) {
$dbForInternal->createCollection($key);
$attributes = [];
$indexes = [];
foreach ($collection['attributes'] as $i => $attribute) {
$dbForInternal->createAttribute(
$key,
$attribute['$id'],
$attribute['type'],
$attribute['size'],
$attribute['required'],
$attribute['signed'],
$attribute['array'],
$attribute['filters'],
);
foreach ($collection['attributes'] as $attribute) {
$attributes[] = new Document([
'$id' => $attribute['$id'],
'type' => $attribute['type'],
'size' => $attribute['size'],
'required' => $attribute['required'],
'signed' => $attribute['signed'],
'array' => $attribute['array'],
'filters' => $attribute['filters'],
]);
}
foreach ($collection['indexes'] as $i => $index) {
$dbForInternal->createIndex(
$key,
$index['$id'],
$index['type'],
$index['attributes'],
$index['lengths'],
$index['orders'],
);
foreach ($collection['indexes'] as $index) {
$indexes[] = new Document([
'$id' => $index['$id'],
'type' => $index['type'],
'attributes' => $index['attributes'],
'lengths' => $index['lengths'],
'orders' => $index['orders'],
]);
}
$dbForConsole->createCollection($key, $attributes, $indexes);
}
$consoleDB->createNamespace($project->getId());

View file

@ -14,6 +14,7 @@ use Utopia\Config\Config;
use Utopia\Database\Validator\Authorization as Authorization2;
use Utopia\Audit\Audit;
use Utopia\Abuse\Adapters\TimeLimit;
use Utopia\Database\Document;
use Utopia\Swoole\Files;
use Utopia\Swoole\Request;
@ -62,6 +63,7 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
$dbForConsole->create();
$audit = new Audit($dbForConsole);
$audit->setup();
@ -69,31 +71,32 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
$adapter->setup();
foreach ($collections as $key => $collection) {
$dbForConsole->createCollection($key);
$attributes = [];
$indexes = [];
foreach ($collection['attributes'] as $i => $attribute) {
$dbForConsole->createAttribute(
$key,
$attribute['$id'],
$attribute['type'],
$attribute['size'],
$attribute['required'],
$attribute['signed'],
$attribute['array'],
$attribute['filters'],
);
foreach ($collection['attributes'] as $attribute) {
$attributes[] = new Document([
'$id' => $attribute['$id'],
'type' => $attribute['type'],
'size' => $attribute['size'],
'required' => $attribute['required'],
'signed' => $attribute['signed'],
'array' => $attribute['array'],
'filters' => $attribute['filters'],
]);
}
foreach ($collection['indexes'] as $i => $index) {
$dbForConsole->createIndex(
$key,
$index['$id'],
$index['type'],
$index['attributes'],
$index['lengths'],
$index['orders'],
);
foreach ($collection['indexes'] as $index) {
$indexes[] = new Document([
'$id' => $index['$id'],
'type' => $index['type'],
'attributes' => $index['attributes'],
'lengths' => $index['lengths'],
'orders' => $index['orders'],
]);
}
$dbForConsole->createCollection($key, $attributes, $indexes);
}
Console::success('[Setup] - Server database init completed...');