Change remove-all syntax.
See original GitHub issuehttps://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:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Since you guys are interested in this, I would like to further suggest separating
query
fromparams
. From my point of view,query
object infind
,update
,patch
andremove
is a natural, universal part of database operations, no matter it’s in a feathers app or not, butparams
are customized specifically for feathers app. So I think it might be better to keepparams
where it is right now, and movequery
object out ofparams
, making it a replacement ofid
infind
,update
,patch
andremove
. So the API may look like this: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
intoparams
just like what we do now).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.