Skip to content
This repository was archived by the owner on Sep 4, 2024. It is now read-only.

Adding a way to specify which mongoose connection to use & typescript typings#16

Open
gabware wants to merge 2 commits into
mattpker:masterfrom
gabware:master
Open

Adding a way to specify which mongoose connection to use & typescript typings#16
gabware wants to merge 2 commits into
mattpker:masterfrom
gabware:master

Conversation

@gabware

@gabware gabware commented Feb 28, 2018

Copy link
Copy Markdown
  • is-master.d.ts : typescript declaration file so we can use "import * as im from 'is-master'"
  • adding a mongooseConnection parameter to im.prototype (and thus options passed to im.prototype.start) to be able to specify which connection is-master should be using. Play nice with mongoose.createConnection.

Comment thread is-master.js
// ensure we aren't attempting to redefine a collection that already exists
if (mongoose.models.hasOwnProperty(this.collection)) {
this.imModel = mongoose.model(this.collection);
var mc = (this.mongooseConnection) ? this.mongooseConnection: mongoose;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just do this.mongooseConnection || mongoose

@caub caub Aug 13, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even better, im.prototype.mongooseConnection = mongoose; up there, as a default

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants