Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
docs(objection): add info about accessing Atlas instance from models
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrossmann committed Jul 17, 2018
1 parent ba6eef8 commit 6a0d5ca
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/objection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ atlas.services.database.connection
atlas.services.database.models
```

#### Accessing the Atlas instance

From within your models you can access the Atlas instance as both a static and instance-level property on the models. This is set up as part of the model loading process during the _prepare_ step.

```js
import { Model } from '@atlas.js/objection'

class User extends Model {
static doThatThing() {
// this refers to the class, ie. this === User
this.atlas
}
doThisThing() {
// this refers to the class' instance, ie. this instanceof User === true
this.atlas
}
}
```

### MigrationAction

This action contains methods for applying and rolling back your migrations. The migration files must export an `up()` and `down()` functions. Both of these functions should return a `Promise` and their first argument is the `knex` client.
Expand Down

0 comments on commit 6a0d5ca

Please sign in to comment.