Skip to content

Added sync of dependant indices#2

Open
MakaryHryshkin wants to merge 8 commits intomasterfrom
feature/sync-of-dependant-indexes
Open

Added sync of dependant indices#2
MakaryHryshkin wants to merge 8 commits intomasterfrom
feature/sync-of-dependant-indexes

Conversation

@MakaryHryshkin
Copy link

This PR introduces new functionality of syncing the entities of dependant elasticsearch indices

* @returns {Promise}
*/

async function syncDependantIndexes(sourceDoc, esOptions, opType) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the file name be changed to use Indexes instead of Indicies?

lib/index.js Outdated
Comment on lines +73 to +78
options.syncDependantIndexes = [options.syncType].includes(
SyncType.DEPENDANT_INDEXES,
SyncType.CURRENT_AND_DEPENDANT_INDEXES
);

options.syncCurrentIndex = [options.syncType].includes(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These includes look backwards. I'd expect options.syncType to be the argument.

doc.emit("es-indexed", err);
doc.constructor.emit("es-indexed", err);

if (err) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this if inside the catch?

* @param {Object} doc
*/
async function postSave(doc) {
async function postSave(doc, next) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have the jsdoc comments, could you add next here and for postRemove?


if (!esOptions.filter || esOptions.filter(doc)) {
if (esOptions.syncDependantIndexes && !data.wasNew) {
await syncDependantIndexes(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're try/catching this function in postRemove. Should we be doing the same here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants