• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

strongloop / loopback-next / 1914 / 2
93%
master: 76%

Build:
Build:
LAST BUILD BRANCH: pm2-deployment-docs
DEFAULT BRANCH: master
Ran 25 Aug 2017 12:35PM UTC
Files 65
Run time 7s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

25 Aug 2017 12:30PM UTC coverage: 93.001%. First build
1914.2

push

travis-ci

bajtos
feat(repository): simplify usage of juggler bridge

**Fix `DefaultCrudRepository` methods to return expected instances**

Before, the type annotation of DefaultCrudRepository said that
CRUD methods are returning Entity instances, but in fact these
methods were returning PersistedModel instances.

Note that PersistedModel is inheriting from juggler's ModelBase class,
while Entity is inheriting from our new Model base class, and these two
inheritance chains never meet.

This commit fixes DefaultCrudRepository to convert internal
PersistedModel instances into the correct Entity instances expected
by the users of this class.

Under the hood, DefaultCrudRepository was changed to expect the Entity
model constructor function in the constructor argument, and build
the backing PersistedModel as an internal implementation detail.
This is possible thanks to static `definition` property required by
all `Model`/`Entity` classes.

**Decouple Entity/Model definition from datasources**

Before:

In order to define a model, one has to already have the datasource
the model will be eventually attached to. This makes dependency
injection impossible, because only the datasource used to create the
model could be used to build a repository instance for that model.

```ts
/* tslint:disable-next-line:variable-name */
const Note = ds.createModel<typeof juggler.PersistedModel>(
  'note',
  {title: 'string', content: 'string'},
  {},
);
```

Now:

Models are defined independently on backing datasources and
repositories, using `class` and `extends` keywords. No magic!

```ts
export class Note extends Entity {
  static definition = new ModelDefinition('note',
    {title: 'string', content: 'string'},
    {});
}
```

**Improve `@model` to build full model definition**

`DefaultCrudRepository` requires Entity-based models to provide their
model definition in the static `definition` property. This was not
supported by `@model` decorator before.

This commit improves `@model` implemen... (continued)

458 of 526 branches covered (87.07%)

Branch coverage included in aggregate %.

1389 of 1460 relevant lines covered (95.14%)

67.26 hits per line

Source Files on job 1914.2
  • Tree
  • List 0
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 1914
  • Travis Job 1914.2
  • f6cc5a6f on github
  • Next Job for on feature/repository-ux (#1928.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc