Skip to content

CodeCoupler UI DataSource Mixin "Loopback"

A DataSource Mixin handling REST endpoints of the Loopback 4 Framework with token based authentication.

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

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

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

Additionally you have to set new added properties in transport with the following properties:

  • 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.

  • 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.

  • include: object[]

Include filter to use on every "read" as object. Should be null if not used.

Syntax:

[ { relation: "modelName", scope: {...} } ]

  1. The property must be an array
  2. The modelName is the the camelCase name of the model starting with a lower letter.
  3. The property "scope" is optional. There you can define recursively filters and further includes.

  4. useGeneratedId: boolean

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

How to set defaults:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import DataSourceLoopback from "@codecoupler/cc-ui"

//Use this object to set the default options used by every new instance.
DataSourceLoopbackR.defaults={...}

//Example for setting the base:
import DataSourceLoopback from "@codecoupler/cc-ui"
$.extend(true, DataSourceLoopback.defaults, {
  transportSettings: {
    base: "/api/"
  }
});

//Or just easy:
DataSourceLoopback.defaults.transportSettings.base = "/api/";
Back to top