Skip to content

Commit

Permalink
Fix ModelClient table getter + now use model package insetead of mode…
Browse files Browse the repository at this point in the history
…l-controller
  • Loading branch information
juanhapes committed Jul 15, 2019
1 parent 4b4090c commit 9e8905b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 34 deletions.
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.1.1] - 2019-07-15
### Changed
- `model` package instead of `model-controller`

### Fixed
- `ModelClient` fixed table getter

## [1.1.0] - 2019-07-04
### Added
- Settings package for handle settings

### Changed
- `Model Client` get method - limited to 1 client
- `ModelClient` get method - limited to 1 client

## [1.0.0] - 2019-06-26
### Added
- `Model Client` for getting client
- `Model Client` and `ActiveClient` - `getByField` method
- `ModelClient` for getting client
- `ModelClient` and `ActiveClient` - `getByField` method
- tests
8 changes: 4 additions & 4 deletions lib/model-client.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
'use strict';

const { Model } = require('@janiscommerce/model-controller');
const Model = require('@janiscommerce/model');
const Settings = require('@janiscommerce/settings');

class ModelClient extends Model {

get settings() {
static get settings() {
return Settings.get('clients') || {};
}

get databaseKey() {
return this.settings.databaseKey || '_default';
return this.constructor.settings.databaseKey || '_default';
}

get table() {
static get table() {
return this.settings.table || 'clients';
}

Expand Down
49 changes: 26 additions & 23 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@janiscommerce/active-client",
"version": "1.1.0",
"version": "1.1.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -34,7 +34,7 @@
"test": "tests"
},
"dependencies": {
"@janiscommerce/model-controller": "^1.4.0",
"@janiscommerce/model": "^1.0.0",
"@janiscommerce/settings": "^1.0.0"
}
}
4 changes: 2 additions & 2 deletions tests/model-client-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('ModelClient', () => {
sandbox.stub(Settings, 'get')
.returns(undefined);

assert.deepEqual(modelClient.table, 'clients');
assert.deepEqual(modelClient.constructor.table, 'clients');

assertSettingsCall();
});
Expand All @@ -45,7 +45,7 @@ describe('ModelClient', () => {
sandbox.stub(Settings, 'get')
.returns({ table: 'custom-table' });

assert.deepEqual(modelClient.table, 'custom-table');
assert.deepEqual(modelClient.constructor.table, 'custom-table');

assertSettingsCall();
});
Expand Down

0 comments on commit 9e8905b

Please sign in to comment.