Skip to content

Use the same Mongoose version for Connection and Schema #24

@bra1n

Description

@bra1n

Hi,

I just noticed that you put "mongoose: *" into the package.json, which will lead to getting unstable versions for Mongoose on an "npm update". This would be fine, by itself, but problems occur when you create the Schema instance with a differnet Mongoose version than the one used for the database connection.
Here's where it breaks:

/node_modules/mongoose/lib/schema.js:362
    throw new TypeError('Undefined type at `' + path +
          ^
TypeError: Undefined type at `paths.sid`
  Did you try nesting Schemas? You can only nest using refs or arrays.
    at Function.Schema.interpretAsType (/node_modules/mongoose/lib/schema.js:362:11)
    at Schema.path (/node_modules/mongoose/lib/schema.js:305:29)
    at Schema.add (/node_modules/mongoose/lib/schema.js:217:12)
    at Schema.add (/node_modules/mongoose/lib/schema.js:212:14)
    at new Schema (/node_modules/mongoose/lib/schema.js:73:10)
    at NativeConnection.Connection.model (/node_modules/mongoose/lib/connection.js:584:14)
    at new SessionStore (/node_modules/session-mongoose/index.js:95:35)
    at Object.<anonymous> (/app.js:51:10)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

Suggested solution: if a connection is passed through the options parameter, you should use the Schema class from that connection, rather than the one from your own Mongoose version, to avoid conflicts.

Cheers,
Steffen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions