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

Feature request: handling of collection #72

Open
syzer opened this issue Oct 2, 2014 · 9 comments
Open

Feature request: handling of collection #72

syzer opened this issue Oct 2, 2014 · 9 comments
Labels

Comments

@syzer
Copy link
Contributor

syzer commented Oct 2, 2014

REST may handle collections:

For bulk POST/PUT it is crazy to call API 1000 times, better solution would be:
POST/PUT request to /api/v1/resource/ should be able to handle collection.

Current example:

curl -X PUT -k -s https://localhost:3000/api/v1/pdfs -d '[
{"id":666, "fileName":"test"},{"id:667","fileName":"test2"}]' -w "\n"  -H "Content-Type: applicatio
n/json"

Current response:

<html><head><title>500 Error</title></head><body><h1>The Server Encountered and Error</h1><div></div></body></html>

Also please note is html not a json

on server:

{ [SyntaxError: Unexpected token ,]
  body: '[{"id":666, "fileName":"test"},{"id:667","fileName":"test2"}]',
  status: 400 }

Expected response:

[{"__v":0,"id":"666","fileName":"test","_id":"542d33abccc4b89c0c9e9972"},
{"__v":0,"id":"667","fileName":"test2","_id":"542d43abccc4b89c0c9e9973"}]
@Zertz
Copy link
Collaborator

Zertz commented Nov 12, 2014

Take a look at this answer from StackOverflow: http://stackoverflow.com/a/1269228/1779688

@syzer
Copy link
Contributor Author

syzer commented Nov 12, 2014

Making algorithmic endpoints for every api endpoint is quite tedious task.
With node we get callback support out of the box.
Also in example we are PUT'ing 2 valid resources... not an single XML/CSV message.

This was referenced May 6, 2015
@Zertz Zertz changed the title Ferture request: handling of collection Feature request: handling of collection Sep 17, 2015
@Zertz Zertz added the feature label Sep 17, 2015
@Quixomatic
Copy link

Was this ever implemented in any form?

@Zertz
Copy link
Collaborator

Zertz commented Feb 2, 2016

Bulk update and delete are very opinionated in the way resource identifiers should be passed and how errors should be handled. Bulk create is relatively simple, but I am reluctant to implement it because it would make our API inconsistent (ie. bulk create, but not update and delete)

@wizardnet972
Copy link

@Quixomatic yes, admin for example. I want to provide UI for the user to edit and save back to database. it doesn't matter what the change is. the admin-user change something in the object and I want to save as it is to db.
the admin-user is special user and understand how the system works.
@Zertz I think that upsert should solve this problem.
if you want I can send PR for this.
I use this option to get collection from the db, provide the UI to connect to collection and the admin-user change the object and save to db.

@wizardnet972
Copy link

In mongoose there is option to upsert bulk data, I think this library should provide a way to support this option, and to solve the problems to achieve the goal.

@StoyanStAtanasov
Copy link
Contributor

StoyanStAtanasov commented Dec 12, 2019

What about bulk queries? I have a use case where I cannot use populate because I am joining on non _id field, so I need a list of queries to be resolved in one call rather in hundreds of calls.

@pimvanderheijden
Copy link

pimvanderheijden commented Dec 12, 2019 via email

@StoyanStAtanasov
Copy link
Contributor

I actually came from GraphQL to this project because GraphQL is complicated for small teams and projects. I needed something simple. I want to jump back to GraphQL when the dev experience is better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants