feathersjs-ecosystem / client

[MOVED] Client side Feathers build
https://github.com/feathersjs/feathers
MIT License
111 stars 27 forks source link

Cannot patch multiple items #267

Closed altwohill closed 6 years ago

altwohill commented 6 years ago

Steps to reproduce

(Simplified example)

import feathers from '@feathersjs/client';
import io from 'socket.io-client';

const socket = io();

const app = feathers()
.configure(feathers.socketio(socket));

app.service("messages").patch(null, 
    { seen: new Date() },
    { query: { seen: { $exists: false } } }
);

Expected behavior

All messages that have not been seen get seen set to the current date.

Actual behavior

An error occurs:

[Unhandled promise rejection: Error: An id must be provided to the 'patch' method]
- node_modules\@feathersjs\client\dist\feathers.js:2117:24 in validateArguments

System configuration

Tell us about the applicable parts of your setup.

Module versions "@feathersjs/client": "^3.5.3",

NodeJS version: 10.6.0

Operating System: iOS, Android

Browser Version: n/a

React Native Version: 0.55

Module Loader: yarn

daffl commented 6 years ago

This is probably not an error from the client but actually from the server. If you want to support multi patch your hooks will have to take that into account as well. In case of the standard feathers-chat the problem is probably in the populate-user hook in https://github.com/feathersjs/feathers-chat/blob/master/src/hooks/populate-user.js#L11.

It should also check for result already being an array like this:

const messages = method === 'find' ? result.data :
  (Array.isArray(result) ? result : [ result ]);