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: removeMany case to _run function (internal) #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meengit
Copy link

@meengit meengit commented Sep 1, 2016

I couldn't delete multiple documents. I know _run is private, but still thought it would be helpful to suggest to fix it:

If you had run till now with something like:
db._run('remove', 'collectionName', { myKey: 'string' });
you couldn't remove many documents.

The code to delete many implied to use it as:
db._run('remove', 'collectionName', [{ myKey: 'string' }]); (check for util.isArray(options))
but that would throw an error [1].

To keep current code running and not to break stuff I introduced the removeMany:
db._run('removeMany', 'collectionName', { myKey: 'string' })

1: db.collection.deleteMany()

What do you think? Or did you have an other idea when you checked for util.isArray(options)?

# FIX
If you had run till now with something like:
`db._run('remove', 'collectionName', { myKey: 'string' });`
 you couldn't remove many documents.

 The code to delete many implied to use it as:
`db._run('remove', 'collectionName', [{ myKey: 'string' }]);` (check for `util.isArray(options)`)
but that would throw an error [1].

To keep current code running and not to break stuff I introduced the `removeMany`:
`db._run('removeMany', 'collectionName', { myKey: 'string' })`

1: [db.collection.deleteMany()](https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/)
@meengit meengit changed the title ADD: removeMany case to _run function ADD: removeMany case to _run function (internal) Sep 1, 2016
@wzrdtales wzrdtales self-assigned this Sep 5, 2016
@wzrdtales
Copy link
Member

I will review this a bit later, short on time currently.

@marc0der
Copy link

marc0der commented Nov 6, 2017

Could this be reviewed and possibly merged please? This would help me a lot in solving a problem I currently have.

Copy link
Contributor

@BorntraegerMarc BorntraegerMarc left a comment

Choose a reason for hiding this comment

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

Looks fine to me

@@ -325,12 +325,11 @@ var MongodbDriver = Base.extend({
else
db.collection(collection).insertOne(options, {}, callbackFunction);
break;
case 'removeMany':
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably be called deleteMany. Makes more sense, no?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for helping on the review :)

The other case is named remove, @marc0der probably oriented after that, so wouldn't be an issue. This is an internal method anyway, but I agree that the mongodb needs some love. If you would be willing to give it a shot you're as always more than welcome to so :)

Choose a reason for hiding this comment

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

Yes, exactly as @wzrdtales says.

@wzrdtales would you hit that merge button please :-) It's been open since 1 September 2017.

Copy link
Member

Choose a reason for hiding this comment

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

@marc0der Nope. There are no tests, if you want you can create a fork from his tree and add them and put this into a new PR and I will he happy to merge :)

Copy link
Member

Choose a reason for hiding this comment

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

Also the altering of remove needs to be removed as this would be a breaking change.

Copy link
Member

Choose a reason for hiding this comment

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

I know that is why I told to fork :)

Choose a reason for hiding this comment

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

Don't worry about it, I've already opted for using a different migration framework.

Copy link
Member

Choose a reason for hiding this comment

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

That is totally ok, I always appreciate people contributing to open source though :)

Choose a reason for hiding this comment

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

As do I, in fact I was using your open source project in my own open source project ;-)

Copy link
Member

Choose a reason for hiding this comment

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

Wasn't a critique though, I'm totally fine if anyone uses something else instead. Open Source means freedom, but shouldn't be considered to be "for free". Everyone and every comany should contribute back, unfortunately many do not. I ment actually this specific PR of @meengit here which I do highly appreciate and I just mentioned it b/c this has been open for a really long time, which I'm sorry for. And the same reason why this has been lying around is which makes me appreciate people that help. I do not have unlimited time, so everyone that contributes is a tremendous help. And that is quite true for every open source project that is not backed by money or a company :)

case 'remove':
// options is the records to insert in this case
Copy link
Member

Choose a reason for hiding this comment

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

Removing and altetering functionality outside a deprication cycle is not allowed, therefore adding a new method is fine, but removing this is not allowed

@meengit
Copy link
Author

meengit commented Feb 11, 2018

Thank you very much for reviewing and commenting.

The pull request is open since

Sep 1, 2016,

or Release v1.1.4 (Feb 5, 2016). If I saw it correctly, tests were not present at this version.

In the meantime, we do not need the db-migrate anymore. However, I am interested writing the tests.

I am not familiar with the project anymore. I have to familiarize myself again. Unfortunately, I am not able to do this before Monday, Feb 19, 2018.

Please let me know if I should write.

@wzrdtales
Copy link
Member

@meengit Yes this has been open for too long that is very true. If you want to write the tests for this that would be fantastic and I can just appreciate your spirit 🦄 even though it has been open for way too long.

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.

4 participants