Skip to content

Commit

Permalink
Fixed MongoDB driver compatibility by using a Model instance instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Nataniel López committed Jan 14, 2020
1 parent 616d7a0 commit b0bf0d8
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 165 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ 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).

## [Unreleased]
### Fixed
- MongoDB driver compatibility by using a Model instance

## [1.1.1] - 2019-12-20
### Fixed
- MongoDB default index `_id_` is now ignored when getting current indexes from database
Expand Down
5 changes: 1 addition & 4 deletions lib/mongodb-index-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ class MongodbIndexCreator {

_saveResults(type, result) {

if(!this.results)
this.results = {};

if(this.results[type])
this.results[type] += result;
else
Expand Down Expand Up @@ -138,7 +135,7 @@ class MongodbIndexCreator {

async _updateIndexes(modelInstance, indexes, useReadDB) {

modelInstance.useReadDB = !!useReadDB; // false if useReadDB is false or not exists, true otherwise
modelInstance.useReadDB = !!useReadDB; // false if useReadDB is false or not exists, true otherwise.

const currentIndexes = await this._getCurrentIndexes(modelInstance);

Expand Down
2 changes: 2 additions & 0 deletions lib/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ModelGenerator {

static getInstanceByDatabaseKey(databaseKey, table) {

/* istanbul ignore next */
class FakeModel extends Model {

get databaseKey() {
Expand All @@ -31,6 +32,7 @@ class ModelGenerator {

static getSessionInstance(client, table) {

/* istanbul ignore next */
class FakeModel extends Model {

static get table() {
Expand Down
98 changes: 49 additions & 49 deletions 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
Expand Up @@ -21,7 +21,6 @@
"license": "ISC",
"homepage": "https://github.com/janis-commerce/mongodb-index-creator.git#readme",
"devDependencies": {
"@janiscommerce/settings": "^1.0.1",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.19.1",
Expand All @@ -38,6 +37,7 @@
"test": "tests"
},
"dependencies": {
"@janiscommerce/settings": "^1.0.1",
"@janiscommerce/model": "^3.5.0",
"@janiscommerce/mongodb": "^1.9.0",
"lllog": "^1.1.2"
Expand Down
Loading

0 comments on commit b0bf0d8

Please sign in to comment.