# BaseDomainEntity

It's an abstract class that simply provides some standard attributes to your entity through props interface.

```
 * @abstract BaseDomainEntity

 * @property ID:DomainId
 * @property createdAt:Date
 * @property updatedAt:Date
 * @property isDeleted:Boolean
 * @property deletedAt:Date | undefined
```

The example, lets create a car with only two attributes `color`and `year`

```typescript
import { 
  BaseDomainEntity, 
  Entity, 
  UniqueEntityID, 
  Result 
} from 'types-ddd';

interface CarProps extends BaseDomainEntity {
  year: number;
  color: string;
}

class Car extends Entity<CarProps> {
  private constructor(props: CarProps, Car.name) {
    super (props, id)
  }
  
  get year (): number {
    return this.props.year;
  }
  
  get color (): string {
    return this.props.color;
  }
  
  public static create (props: CarProps): Result<Car> {
    return Result.ok<Car>(new Car(props));
  }
}

const car = Car.create({ 
  ID: DomainId.create(),
  year: 2021, 
  color: 'red' 
}).getResult();

```

```
Accessible attributes for car
> car.color
> car.createdAt
> car.deletedAt
> car.equals
> car.id
> car.isDeleted
> car.updatedAt
> car.year
> car.getHashCode
```

![](https://274711142-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYyqlHfWL4Tal2TTUf0%2F-Me7sYZq_cAcJ0IZTMJz%2F-Me86zlhkT9Jn6sYpN98%2Fcar.png?alt=media\&token=d663cf85-e78a-4a89-b665-d19df66d8f20)
