Skip to content

Commit

Permalink
Version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jormaechea committed Oct 1, 2019
1 parent 4052adf commit f72b3a3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [3.0.0] - 2019-09-12
### Changed
- Client injection replaced by Session injection (**BREAKING CHANGE**)

## [2.1.0] - 2019-09-12
### Removed
- `ENV` vars config documentation
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
npm install @janiscommerce/model
```

## Client injection
The client injection is useful when you have a dedicated database per client.
Using the public setter `client`, the client will be stored in the `controller` instance.
All the controllers and models getted using that controller will have the client injected.
## Session injection
The session injection is useful when you have a dedicated database per client.
Using the public setter `session`, the session will be stored in the `controller` instance.
All the controllers and models getted using that controller will have the session injected.

## Database Dispatcher
The `Model` uses [Database Dispatcher](https://www.npmjs.com/package/@janiscommerce/database-dispatcher) for getting the correct **DBDriver** for a `Model`.
Expand Down Expand Up @@ -46,8 +46,8 @@ Using [Settings](https://www.npmjs.com/package/@janiscommerce/settings), with se
}
```

### Database connection configurated with client injected
When your `Model` is a Client Model, and the database connection settings are in the injected client, you don't need to configurate the `databaseKey`.
### Database connection configurated with session injected
When your `Model` is a Client Model, and the database connection settings are in the injected session, you don't need to configurate the `databaseKey`.
You can add database connection settings by adding the field names from the received client that contains the settings, with the setting what will be passed to the DBDriver. Also you can add config for read/write databases.

**Example of settings:**
Expand Down Expand Up @@ -79,7 +79,7 @@ You can add database connection settings by adding the field names from the rece
}
}

/*
/*

Received client:

Expand Down
8 changes: 8 additions & 0 deletions lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ const DEFAULT_PAGE_LIMIT = 500;

class Model {

set session(session) {
this._session = session;
}

get session() {
return this._session;
}

static get defaultPageLimit() {
return DEFAULT_PAGE_LIMIT;
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@janiscommerce/model",
"version": "2.1.0",
"version": "3.0.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit f72b3a3

Please sign in to comment.