* Get the identity value. If the identity is a composite key, returns * an object.
()
| 465 | * an object. |
| 466 | */ |
| 467 | getId(): any { |
| 468 | const definition = (this.constructor as typeof Entity).definition; |
| 469 | const idProps = definition.idProperties(); |
| 470 | if (idProps.length === 1) { |
| 471 | return (this as AnyObject)[idProps[0]]; |
| 472 | } |
| 473 | if (!idProps.length) { |
| 474 | throw new Error( |
| 475 | `Invalid Entity ${this.constructor.name}:` + |
| 476 | 'missing primary key (id) property', |
| 477 | ); |
| 478 | } |
| 479 | return this.getIdObject(); |
| 480 | } |
| 481 | |
| 482 | /** |
| 483 | * Get the identity as an object, such as `{id: 1}` or |
no test coverage detected