feathers-sequelize: update not working?

Steps to reproduce

submit http PUT for a resource passing body to be used for update operation

Expected behavior

identified resource should be updated

Actual behavior

PUT returns updated version of object, but no call to database is made leaving persisted resource unchanged

  app:http:steps http-update: method='PUT', url='http://localhost:3000/alerts/3', data={ username: 'user-3', folder: '/folder-3', file: 'file-3', bytes: 4, message: 'message-4' }, headers=undefined +0ms
  feathers:rest REST handler calling `update` from `/alerts/3` +74ms
Executing (default): SELECT `id`, `username`, `folder`, `file`, `bytes`, `message`, `createdAt`, `updatedAt` FROM `Alerts` AS `Alert` WHERE `Alert`.`id` = '3';

PATCH seems to be working correctly…

i stepped thru in a debugger, but wasn’t sure exactly what to look for, if helpful, i can do so again with some guidance as to what to check into…

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that’s not working): feathers: 2.1.3 feathers-rest: 1.7.3 feathers-sequelize: 2.0.0

NodeJS version: 8.1.0

Operating System: osx

fwiw: going against mysql 5.7.18 executing in a cucumber-js test…

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

@snewell92 the raw option in feathers-sequelize world means that the data object returned by the database adapter is a “plain” JavaScript object. It’s not related to the database query itself. Sequelize works in part by attaching observables to a number of object properties in order to decide whether it needs to execute a database query.

Other feathers hooks seem to have a hard time operating on Sequelize instances - the workaround suggested here is to always use Sequelize instances in the service, which will break many common hooks. A more complete workaround is in the docs here: https://docs.feathersjs.com/api/databases/sequelize.html#working-with-sequelize-model-instances

This involves converting between the Sequelize representation of the data and a “plain” JavaScript Object representation depending on what is needed for the hooks you’re using. So when using Feathers with Sequelize, you have to be very mindful of the data representation required by each hook.

@joeblubaugh no, you maybe missed the first option:

app.use('/people', service({
    Model,
    raw: false
}));

Declaring raw:false in your Model prevents the need to use a hook.

@tony-kerz does the operation work if you have a before hook which sets sequelize: {raw: false} ?

e.g.

    update: [ hook => { hook.params.sequelize = { raw: false }; return hook; } ],