1

i'd need to override the remote method find in llopback. i tried this in my model:

'usestrict';

module.exports = function(Movimenti) {
  Movimenti.once('attached', function(obj) {
    Movimenti.find = function(filter, empty, cb) {
      cb(null, this.find({
        "where": {
          "mov_utente_fk": 2
        }
      }));
    }
  });
};

but i get this error:

500 Maximum call stack size exceeded

could you help me??

matteo
  • 2,121
  • 4
  • 20
  • 33
  • Possible duplicate of [Maximum call stack size exceeded error](https://stackoverflow.com/questions/6095530/maximum-call-stack-size-exceeded-error) – Luka Čelebić Oct 09 '17 at 13:31
  • the error is the same, but my problem is that I should override a method in LoopBack, and I do not know if I'm doing the right way!! – matteo Oct 09 '17 at 13:37
  • a jQuery function for loopback ??? – matteo Oct 09 '17 at 14:05

1 Answers1

0

You can use scope in model definition of your model JSON file:

"scope": {
        "where": {
            "mov_utente_fk" : 2
        }
    }

From the Loopback Documentation:

Scope enables you to set a scope that will apply to every query made by the model's repository

Burak Özalp
  • 51
  • 2
  • 8