Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ module.exports = {
```

### `get`: \<Function\> _(Default: `null`)_
The `get` function is called when transforming entities. With this function, you can modify an entity value before sending it back to the caller or calculate a value from other fields of the entity in virtual fields.
The `get` function is called when transforming entities. With this function, you can modify an entity value before sending it back to the caller or calculate a value from other fields of the entity in virtual fields. If it is a String, it should be a service method name that will be called.
_It can be asynchronous._

### Callback parameters
Expand Down
3 changes: 2 additions & 1 deletion src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ module.exports = function (mixinOpts) {
}

// Virtual or formatted field
if (_.isFunction(field.get)) {
// Syntax: ({ entity }) => `${entity.firstName} ${entity.lastName}`
if (field.get) {
values = await Promise.all(
values.map(async (value, i) =>
this._callCustomFunction(field.get, [
Expand Down