Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Cannot patch multiple items #267

Closed
altwohill opened this issue Jul 19, 2018 · 1 comment
Closed

Cannot patch multiple items #267

altwohill opened this issue Jul 19, 2018 · 1 comment

Comments

@altwohill
Copy link

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
Copy link
Member

daffl commented Jul 19, 2018

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 ]);

@daffl daffl closed this as completed Sep 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants