Skip to content

Commit

Permalink
fix: this.definition.idName is not a function
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Buceta <frbuceta@gmail.com>
  • Loading branch information
frbuceta committed Oct 24, 2020
1 parent bbe0397 commit 0de5522
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/repository/src/__tests__/unit/model/model.unit.ts
Expand Up @@ -522,6 +522,16 @@ describe('model', () => {
});
});

it('gets id of an object through a static method', () => {
const userId = User.getIdOf({
id: '53',
email: 'loopback@localhost',
password: 'l00pback',
firstName: 'Loopback User',
});
expect(userId).to.eql('53');
});

describe('rejectNavigationalPropertiesInData', () => {
class Order extends Entity {
static definition = new ModelDefinition('Order')
Expand Down
3 changes: 2 additions & 1 deletion packages/repository/src/model.ts
Expand Up @@ -437,7 +437,8 @@ export abstract class Entity extends Model implements Persistable {
return entityOrData.getId();
}

const idName = this.definition.idName();
// const idName = this.definition.idName();
const idName = this.getIdProperties()[0];
return entityOrData[idName];
}

Expand Down

0 comments on commit 0de5522

Please sign in to comment.