Skip to content

Commit

Permalink
fix: Fix compilation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain Lenzotti committed Jul 1, 2020
1 parent 32d2d72 commit e1134d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 2 additions & 3 deletions packages/mongoose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"devDependencies": {
"@tsed/common": "5.59.3",
"@tsed/core": "5.59.3",
"@tsed/testing-mongoose": "5.59.3"
"@tsed/core": "5.59.3"
}
}
}
10 changes: 8 additions & 2 deletions packages/mongoose/src/utils/createModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {nameOf} from "@tsed/core";
import * as mongoose from "mongoose";
import {Connection} from "mongoose";

/**
* Create an instance of mongoose.model from a class.
Expand All @@ -18,7 +19,12 @@ export function createModel<T>(
name: string = nameOf(target),
collection?: string,
skipInit?: boolean,
connection = mongoose
connection?: Connection
) {
return connection.model(name, schema, collection, skipInit);
/* istanbul ignore else */
if (connection) {
return connection.model(name, schema, collection);
}

return mongoose.model(name, schema, collection, skipInit);
}

0 comments on commit e1134d8

Please sign in to comment.