3

What is the Difference between extending Model vs Entity in loopback4?

@model
export class Todo extends Entity {}

@model()
export class Todo2 extends Model {}
slim
  • 45
  • 8

2 Answers2

0

From https://loopback.io/doc/en/lb4/Model-generator.html

  • An Entity is a persisted model with an identity (ID).

  • A Model is a business domain object.

k_jello
  • 9
  • 1
0

Entity: A domain object that has an identity (ID). Its equality is based on the identity. For example, Customer can be modeled as an Entity because each customer has a unique customer id. Two instances of Customer with the same customer id are equal since they refer to the same customer. For example, this is how a Customer can be modelled::

Model: A domain object that does not have an identity (ID). Its equality is based on the structural value. For example, Address can be modeled as a Model because two US addresses are equal if they have the same street number, street name, city, and zip code values. For example, this is how a Address can be modelled::

From: https://loopback.io/doc/en/lb4/Model.html#overview