Skip to content

CodeCoupler UI DataSource Mixin "Loopback"

A DataSource mixin handling REST endpoints of the Loopback 4 Framework.

Using this mixin you can set the configuration property type to loopback to enable the following features and handle Loopback endpoints. If you do not set the type the DataSource will work like you did not integrate this mixin.

In the configuration you can use all the DataSource options except:

  • transport.read
  • transport.create
  • transport.destroy
  • trasport.update

IMPORTANT: Set at least the schema.model.id, otherwise update and delete will not work.

The options serverFiltering, serverSorting and serverPaging will be set by default to true. This can be overwritten.

The following new added properties must be set:

transport.base: String

The base URI to the REST API you want to access. This is the URI without the modelname. The URI can optionally ends with a slash, but it must not.

transport.controller: String

The name of the controler you want to access. The complete URI will be built by concatenating the base URI with the controller name.

transport.useGeneratedId: Boolean

This defaults to true and the id field will be deleted in the create request. Otherwise Loopback will throw an exception.

The following option can be used in combination with @codecoupler/cc-api-auth:

transport.polling: Boolean

The default is false. If you set this to true an additional header no-session-refresh: 1 will be sent. This tells the cc-api-auth backend not to refresh the authorization token. Use this setting for polling DataSources.

Additionally a new added property can be used to include relations:

include: Object[] | Object | String | String[]

Loopback include filter to use on each "read". Should be null if not used.

The full syntax is:

[ { relation: "modelName1", scope: {...} }, { relation: "modelName2", scope: {...} } ]

You can for the sake of simplicity use the following shortcuts:

{ relation: "modelName1", scope: {...} }: Include only one relation.

"modelName1": Include only one relation without any scope.

["modelName1","modelName2"]: Include relations without any scopes.

HINT: The modelName is the the camelCase name of the model starting with a lower letter.

More informations about the loopback include filter: https://loopback.io/doc/en/lb4/Include-filter.html#nodejs-api