-
Notifications
You must be signed in to change notification settings - Fork 2
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
add the key column feature to update existing documents #64
Conversation
// If an update key is found, we try to update the document. | ||
// It also means that we are in a "simple" import (CSV or Excel), | ||
// not in a full import process like Gzip with JSON formats. | ||
if (updateKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if an update key is found, we call self.insertOrUpdateDocWithKey
rather than self.insertOrUpdateDoc
because it has its own logic.
|
||
if (!matchingDraft && !matchingPublished) { | ||
return insert(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if neither the draft nor the published version matched the column key value, then we insert the doc.
aposDocId: matchingDraft.aposDocId | ||
}) | ||
.toObject(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update all versions, even if one does not match the column key value.
lib/methods/import.js
Outdated
// Manually set `modified: false` because `setModified` option is not taken into account | ||
// in the `update` method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes...
lib/methods/import.js
Outdated
} | ||
} | ||
|
||
self.handleRichTextFields(manager, doc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was not taken into account when importing a CSV (or Excel file)
lib/methods/import.js
Outdated
return method === 'update' | ||
? manager[method](_req, doc, { setModified: false }) | ||
: manager[method](_req, '_home', 'lastChild', doc, { setModified: false }); | ||
await manager.convert(_req, doc, docToImport); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, we need to convert the doc for "not-fully-exported" CSV entries like:
type,title,main,openGraphTitle
default-page,d2,<p><em>rich</em> <strong>text</strong> 2</p>,some text 2
i.e "man-made" import files, not created from our import-export module
@boutell The PR just need some adaptation in the mocha tests to pass, but the general code is reviewable |
Strategy feels good, like the attention to detail in various scenarios |
Summary
Adds
Thanks to this, this module reaches parity with the deprecated
@apostrophecms/piece-type-importer
module.Fixes
See PR comments.
What kind of change does this PR introduce?
(Check at least one)
Make sure the PR fulfills these requirements:
If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.
Other information: