> For the complete documentation index, see [llms.txt](https://samypesse.gitbook.io/blini/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://samypesse.gitbook.io/blini/guides/discriminators.md).

# Discriminators

Discriminators are a schema inheritance mechanism. They enable you to have multiple models with overlapping schemas on top of the same underlying MongoDB collection.

```javascript
const eventSchema = new Schema({
    type: Type.String(),
    time: Type.Date()
});

class Event extends Model(eventSchema, connection, 'Event') {
    get summary() {
        return `${this.time}: event ${this.type}`;
    }
}
```

```javascript
const visitEventSchema = new Schema({
    url: Type.String()
});

class VisitEvent extends Event.discriminate({ type: 'visit' }, visitEventSchema) {
    get summary() {
        return `${this.time}: a click on ${this.url}`;
    }
}
```
