express-restify-mongoose icon indicating copy to clipboard operation
express-restify-mongoose copied to clipboard

Feature request: handling of collection

Open syzer opened this issue 10 years ago • 9 comments

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"}]

syzer avatar Oct 02 '14 11:10 syzer

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

Zertz avatar Nov 12 '14 04:11 Zertz

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.

syzer avatar Nov 12 '14 09:11 syzer

Was this ever implemented in any form?

Quixomatic avatar Feb 01 '16 17:02 Quixomatic

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)

Zertz avatar Feb 02 '16 16:02 Zertz

@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 avatar Nov 16 '19 05:11 wizardnet972

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.

wizardnet972 avatar Nov 16 '19 05:11 wizardnet972

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.

StoyanStAtanasov avatar Dec 12 '19 11:12 StoyanStAtanasov

I hear GraphQL

Op do 12 dec. 2019 om 12:20 schreef StoyanStAtanasov < [email protected]>:

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.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/florianholzapfel/express-restify-mongoose/issues/72?email_source=notifications&email_token=AFL2SSS2J33HY7M55TPOWLTQYINBXA5CNFSM4AVH2QL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGWLEOQ#issuecomment-564965946, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFL2SSTEAOXMVXYPT4KNLCDQYINBXANCNFSM4AVH2QLQ .

pimvanderheijden avatar Dec 12 '19 15:12 pimvanderheijden

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.

StoyanStAtanasov avatar Dec 12 '19 15:12 StoyanStAtanasov