-
Notifications
You must be signed in to change notification settings - Fork 3
Add overwrite and skip options to Appwrite destination #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e808bdd
0ef24fa
685698e
a3a84bd
8c85cbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,27 @@ class Appwrite extends Destination | |
| */ | ||
| private array $rowBuffer = []; | ||
|
|
||
| private bool $overwrite = false; | ||
| private bool $skip = false; | ||
|
|
||
| public function setOverwrite(bool $overwrite): self | ||
| { | ||
| if ($overwrite && $this->skip) { | ||
| throw new \InvalidArgumentException('Cannot set both overwrite and skip to true.'); | ||
| } | ||
| $this->overwrite = $overwrite; | ||
| return $this; | ||
| } | ||
|
|
||
| public function setSkip(bool $skip): self | ||
| { | ||
| if ($skip && $this->overwrite) { | ||
| throw new \InvalidArgumentException('Cannot set both skip and overwrite to true.'); | ||
| } | ||
| $this->skip = $skip; | ||
| return $this; | ||
| } | ||
greptile-apps[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * @param string $project | ||
| * @param string $endpoint | ||
|
|
@@ -986,7 +1007,7 @@ protected function createRecord(Row $resource, bool $isLast): bool | |
| $this->cache->get($resource->getName()) | ||
| ); | ||
|
|
||
| if ($exists) { | ||
| if ($exists && !$this->overwrite) { | ||
| $resource->setStatus( | ||
| Resource::STATUS_SKIPPED, | ||
| 'Row has already been created' | ||
|
|
@@ -1067,10 +1088,20 @@ protected function createRecord(Row $resource, bool $isLast): bool | |
| } | ||
| } | ||
| } | ||
| $dbForDatabases->skipRelationshipsExistCheck(fn () => $dbForDatabases->createDocuments( | ||
| 'database_' . $databaseInternalId . '_collection_' . $tableInternalId, | ||
| $this->rowBuffer | ||
| )); | ||
| $collectionName = 'database_' . $databaseInternalId . '_collection_' . $tableInternalId; | ||
|
|
||
| if ($this->overwrite) { | ||
| $dbForDatabases->skipRelationshipsExistCheck(fn () => $dbForDatabases->upsertDocuments( | ||
| $collectionName, | ||
| $this->rowBuffer | ||
| )); | ||
| } else { | ||
| $dbForDatabases->skipRelationshipsExistCheck(fn () => $dbForDatabases->createDocuments( | ||
| $collectionName, | ||
| $this->rowBuffer, | ||
| ignore: $this->skip | ||
| )); | ||
|
Comment on lines
+1093
to
+1103
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When The same gap exists for the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cache is already updated at the For the |
||
| } | ||
|
|
||
| } finally { | ||
| $this->rowBuffer = []; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.