Skip to content
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 update and delete functionality #8

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Peter-Van-Drunen
Copy link

@Peter-Van-Drunen Peter-Van-Drunen commented Sep 13, 2018

This PR aims to add update and delete functionality to the module. See issue #7.

There may be room for improvement before this should be merged. Let me know what you think @AbdullahAli @fabienjuif

Added an enum for allowed operation types and set up the basic mechanism for running different operations.
Tests that pass on master now pass with the modified API in place.
update operation now passes a simple test.
Added a few more basic tests for the update operation
added one more basic test to the spec
Cleaned up the code somewhat. Renamed some of the variables in index_spec.js to avoid shadowing.
@fabienjuif
Copy link
Collaborator

@Peter-Van-Drunen I haven't forgotten this PR but I have some work to do on my own. And this PR is quite big 😅

};

// Utility for writing to the db with the correct operation
const writeToDB = async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we could cache this function result before calling it.
Here you call this function every time we need to write to db (line 84).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Plus the error about invalid operation will be triggered before the stream is used.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I speak about which operation to choose (which callback)

}
}
});

writable.on('finish', async () => {
try {
if (records.length > 0) await insert();
if (records.length > 0) await writeToDB();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll fell more confortable if you reset records here too.
That's why I put it to insert at first place :)

@@ -7,50 +7,95 @@ module.exports = {
// default config
{
batchSize: 1,
insertOptions: { w: 1 },
operationType: 'insert'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here I have the feeling you break the API for some users.
Maybe we should keep insertOptions for now, and use it into operation.insert?

@Peter-Van-Drunen
Copy link
Author

@fabienjuif Thanks for the feedback, I will resolve these problems when I get the chance.

@fabienjuif
Copy link
Collaborator

Yeah sure @Peter-Van-Drunen you did a great job already 👍
I'll set a reminder about this PR in a month.

If you don't have time since then, I'll try to make the patch needed ;)

@ivan133
Copy link

ivan133 commented Jun 23, 2022

Any news about merging this PR?

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