question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change remove-all syntax.

See original GitHub issue

https://github.com/feathersjs/feathers-mongoose/blob/master/src/service.js#L191

The user should be required to pass both null and {} like service.remove(null, {}) in order to remove all records. Since the default query is already set to {}, if an id in the app accidentally gets set to null and the user tries service.remove(id) they just wiped out the entire collection in the database. If you guys agree, I will make the changes.

We should check if the id is null and also check if at least a query object was passed in order to remove.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
beeplincommented, Apr 2, 2016

Since you guys are interested in this, I would like to further suggest separating query from params. From my point of view, query object in find, update, patch and remove is a natural, universal part of database operations, no matter it’s in a feathers app or not, but params are customized specifically for feathers app. So I think it might be better to keep params where it is right now, and move query object out of params, making it a replacement of id in find, update, patch and remove. So the API may look like this:

find(id/query, params [, callback])
get(id, params [, callback]) 
create(data, params [, callback])
update(id/query, data, params [, callback]) 
patch(id/query, data, params [, callback])
remove(id/query, params [, callback]) 

This design would be more compatible with the traditional mongo syntax, and at the same time allows users to specify particular params for feathers, and also be more backward-compatible with our current syntax (by allowing put query into params just like what we do now).

2reactions
beeplincommented, Apr 1, 2016

yes eric, personally I agree with you that setting id to null to make multiple change is not an ideal design. I prefer what meteor did in minimingo: when the first parameter is a string or objectid, it makes single modification; when the first parameter is an object, it would be taken as a query object and makes multiple modification.

I also agree that since this is related to all adapters, it is not hurry to make decision to change tje design.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ArrayList removeAll() method in Java with Examples
Syntax : public boolean removeAll(Collection c) ... Returns Value: This method returns true if this list changed as a result of the call....
Read more >
Java ArrayList removeAll()
The syntax of the removeAll() method is: arraylist.removeAll(Collection c);. Here, arraylist is an object of the ArrayList class.
Read more >
ArrayList removeAll() method in Java
Here is the method syntax: boolean removeAll(Collection<?> c) Where c is a collection that contains elements to be removed from this list.
Read more >
List<T>.RemoveAll(Predicate<T>) Method
The RemoveAll method is used to remove all entries ending with "saurus". It traverses the list from the beginning, passing each element in...
Read more >
C# RemoveAll Example (Delete From List)
First example. This example code deletes all elements with values of 2. The lambda expression, with the => syntax, matches elements with value ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found