-
Notifications
You must be signed in to change notification settings - Fork 653
add get-apos-doc-id and set-apos-doc-id tasks #5136
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
Changes from 3 commits
0fbae23
2c90524
89bd6b8
047de21
2d765bc
51964a3
1be46d9
2dc890c
dc318ce
82b3bf1
fd2c8ba
709ca5d
c33903c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1851,20 +1851,15 @@ module.exports = { | |
| if (!_id && !slug) { | ||
| throw self.apos.error('invalid', 'Either _id or slug must be provided'); | ||
| } | ||
| if (!locale) { | ||
| if (!_id && !locale) { | ||
| throw self.apos.error('invalid', 'Missing locale'); | ||
| } | ||
|
|
||
| // const req = self.apos.task.getReq({ mode: 'draft', locale }); | ||
| const aposLocale = new RegExp(`^${self.apos.util.regExpQuote(locale)}:`); | ||
| const criteria = _id | ||
|
Member
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. One last thing, sorry... since the _id parameter has to be a full _id, which already contains the locale, there's no need to make locale mandatory or even part of the query when _id is present. (Technically we don't need to make a query at all when _id is the argument, because _id already contains aposDocId, but I like the idea of making the query because it validates that the document actually does exist.) |
||
| ? { | ||
| _id, | ||
| aposLocale | ||
| } | ||
| ? { _id } | ||
| : { | ||
| slug, | ||
| aposLocale | ||
| aposLocale: new RegExp(`^${self.apos.util.regExpQuote(locale)}:`) | ||
| }; | ||
|
|
||
| const doc = await self.apos.doc.db | ||
|
|
@@ -1933,7 +1928,7 @@ module.exports = { | |
| tasks(self) { | ||
| return { | ||
| 'get-apos-doc-id': { | ||
| usage: 'Retrieve the aposDocId from the _id or slug, and the locale. Usage: "node app.js @apostrophecms/doc:get-apos-doc-id --_id=pfh0haxfpzowht3oi213cqos:fr:draft --locale=fr" or "node app.js @apostrophecms/doc:get-apos-doc-id --slug=test --locale=fr"', | ||
| usage: 'Retrieve the aposDocId from the _id or slug, and the locale. Usage: "node app.js @apostrophecms/doc:get-apos-doc-id --_id=pfh0haxfpzowht3oi213cqos:fr:draft" or "node app.js @apostrophecms/doc:get-apos-doc-id --slug=test --locale=fr"', | ||
| task: async (argv) => { | ||
| const { | ||
| _id, slug, locale | ||
|
|
||
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.
How did this creep into this PR? It's not hurting anything