How to create getter and setter overrides?

I would like to encrypt fields similar to this example with mongoose: https://gist.github.com/kljensen/7505729

The code in the link above maps the field to the decrypt() custom function for get and encrypt() for set .

This leads to the fact that the value of plain text is encrypted during storage and decrypted during extraction.

How do I override getters and setters for a model property in Loopback?

+5
loopbackjs strongloop
source share
1 answer

You can configure the setter and getter as follows:

 <Model>.setter['myProp'] = function(val) {}; 

See an example in LoopBack common / models / user.js

+6
source share

All Articles