DEV Community

[Comment from a deleted post]
Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

But, I don't want to use traditional REST...

  • My Read (aka GET) does have a JSON body (for easy integration with MongoDB), so I have to resort to POST instead.
  • What should I use for uploading files?

So, mostly everything is POST, right?

Collapse
 
rcarlson profile image
Robert Carlson • Edited

I want to clarify that while I understand your need to use a POST to get, you should always try to avoid this. A GET is a much cleaner and SAFE way to return data. When calling a GET you know that the state of your data is not going to change, whereas a POST communicates to the caller that something CAN happen to the state of the DB.

Collapse
 
rcarlson profile image
Robert Carlson

File uploading is done using a multi-part form POST.

As far as using a POST to get data I totally understand that. Sometimes its just too much to send up complex aggregations and filters through a query-string. That being said, my team and I actually built a solution around this problem called 'Projections' which allows you to store complex MongoDB queries on the server and simply reference them as basic GET endpoints. You might find this solution a bit easier to implement as well. meshydb.com/blog/stored-procedures...