1
votes

I am looking for a way to include the result of a remote method when I make a query.

For example: I am querying Customer models. To include a related model you would use the include filter { filter: { include: ['orders'] } }.

I need to do some processing on some related models before returning results.

What I am looking for is something akin to virtual properties from Mongoose. Is this possible or do I have to create a separate request for each customer after results returned?

1

1 Answers

0
votes

You can extend the model class and add properties with getter function so that it will get values from other persisted properties.

For example:

module.exports = function(Person) {
  Object.defineProperty(Person.prototype, 
    "fullName", 
    {
      get : function() { return this.firstName + ' ' + this.lastName; }
    });
}

http://docs.strongloop.com/display/LB/Extend+your+API