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

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

Build:
Build:
LAST BUILD BRANCH: pm2-deployment-docs
DEFAULT BRANCH: master
Ran 25 Aug 2017 12:35PM UTC
Jobs 2
Files 65
Run time 3min
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

pending completion
1914

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

58 of 58 new or added lines in 5 files covered. (100.0%)

1389 of 1460 relevant lines covered (95.14%)

134.51 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
1
100.0
packages/repository/src/decorators/repository.ts
1
100.0
packages/repository/src/model.ts
Jobs
ID Job ID Ran Files Coverage
1 1914.1 25 Aug 2017 12:38PM UTC 0
93.0
Travis Job 1914.1
2 1914.2 25 Aug 2017 12:35PM UTC 0
93.0
Travis Job 1914.2
Source Files on build 1914
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #1914
  • f6cc5a6f on github
  • Next Build on feature/repository-ux (#1928)
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