feathers-mongoose: patch doesn't throw correct object

Using auth for facebook generated by feathers cli, patch function fails , the issue is with the data parameter in service.js on line 164.

For more verbose explanation

  feathers-authentication:oauth2 Updating user: 57b71962784bec9f311e4462 +821ms
  feathers:rest Error in REST handler: `Invalid atomic update value for $__original_remo
ve. Expected an object, received function` +11ms
  feathers-authentication:middleware An authentication error occurred. +2ms Error: Inval
id atomic update value for $__original_remove. Expected an object, received function
    at Query._castUpdate (/home/shriyans/Projects/test-app/node_modules/mongoose/lib/que
ry.js:2378:13)
    at Query.update (/home/shriyans/Projects/test-app/node_modules/mongoose/lib/query.js
:2161:22)
    at Function.update (/home/shriyans/Projects/test-app/node_modules/mongoose/lib/model
.js:2056:13)
    at Object.patch (/home/shriyans/Projects/test-app/node_modules/feathers-mongoose/lib
/service.js:255:27)
  at /home/shriyans/Projects/test-app/node_modules/feathers-hooks/lib/hooks.js:74:31
    at new Promise (/home/shriyans/Projects/test-app/node_modules/core-js/modules/es6.pr
omise.js:191:7)
    at /home/shriyans/Projects/test-app/node_modules/feathers-hooks/lib/hooks.js:58:16
    at run (/home/shriyans/Projects/test-app/node_modules/core-js/modules/es6.promise.js:87:22)
    at /home/shriyans/Projects/test-app/node_modules/core-js/modules/es6.promise.js:100:28
    at flush (/home/shriyans/Projects/test-app/node_modules/core-js/modules/_microtask.j
s:18:9)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 19 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@ekryski @daffl I also didn’t know well about how mongoose works (I still don’t know , Db is my weakest tool) , but if lean gives us performance and also solves core issues , then i think it should be part of cli tool (as it would help beginers like me). I have been busy for a long while but next week onward i’ll try to figure out the core issue. Also, i just want to say , you guys are REALLY doing an awesome job. I have been using feathers for a project in my company for a while. And it is AWESOME !!! Before starting feathers, i had little to no clue over service based architecture and discovered feathers because meteor wasn’t giving me enough freedom ( too much “magic” happening , if i put it nicely). Thanks a lot.

I’ve had this issue as well for a bit now.

I tried following @madmantalking’s advice but: fix 1: I didn’t want to be updating imported libraries. fix 2: I tried googling how to set lean globally and couldn’t get it to work.

As I’m just playing around with the framework right now I found a not so bad approach to at least continue testing it.

In the generated code file src/services/user/index.js I added lean: true to the options passed into the service:

  const options = {
    Model: user,
    paginate: {
      default: 5,
      max: 25
    },
    lean: true,
  };

  // Initialize our service with any options it requires
  app.use('/users', service(options));

I’m not even sure what the lean option does but at least I can play around with featherjs more now! Maybe that will help someone play around as well until a fix comes out.

@ekryski I am still able to reproduce the same error, and again am being able to solve it by changing line 215 in src/service.js

return this.Model
     .update(query, data._doc, options)

the problem is still with toObject() i guess.