question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Model is not a constructor (mongoose

See original GitHub issue

factory-girl version 4.2.2

I think this is related to #63. I am using Mongoose but otherwise used the same set up suggested there.

var fg = require('factory-girl');

var adapter = new fg.MongooseAdapter();
factory = fg.factory;
factory.setAdapter(adapter);

When running npm test I get:

TypeError: Model is not a constructor
    at MongooseAdapter.build (/Users/stoebelj/freecodecamp/voting/node_modules/factory-girl/index.js:703:14)
    at Factory._callee2$ (/Users/stoebelj/freecodecamp/voting/node_modules/factory-girl/index.js:155:33)
    at tryCatch (/Users/stoebelj/freecodecamp/voting/node_modules/regenerator-runtime/runtime.js:63:40)
    at Generator.invoke [as _invoke] (/Users/stoebelj/freecodecamp/voting/node_modules/regenerator-runtime/runtime.js:337:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/stoebelj/freecodecamp/voting/node_modules/regenerator-runtime/runtime.js:96:21)
    at step (/Users/stoebelj/freecodecamp/voting/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/stoebelj/freecodecamp/voting/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13

Am I missing something?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

73reactions
landrykapelacommented, Feb 21, 2019

In my case I cleared many errors including this one after correcting this: module.export to module.exports 😊

18reactions
musial-adamcommented, Jul 26, 2019

In my case I cleared many errors including this one after correcting this: module.export to module.exports 😊

And I spent an hour or so just to find out that I wrote exports.module instead of module.exports…

Read more comments on GitHub >

github_iconTop Results From Across the Web

mongoose TypeError: Schema is not a constructor
I have encountered the same thing. I have previous code like this var mongoose = require('mongoose'); var Schema = mongoose.
Read more >
Can't export/require a module mongoose model: TypeError
I'm trying to export a mongoose model and require it on another file. ... a module mongoose model: TypeError: User is not a...
Read more >
TypeError: Schema is not a constructor (Example) - Treehouse
TypeError : Schema is not a constructor. Hi all. I wonder if someone can help me, please. :) Here's my code: 'use strict'...
Read more >
TypeError: Model is not a Constructor-mongodb - appsloveworld
Making a MongoDB call from a react component on Form Submit with Mongoose throws an error - TypeError: Group is not a constructor...
Read more >
Javascript – mongoose TypeError: Schema is not a constructor
Javascript – mongoose TypeError: Schema is not a constructor ... I find it very strange as I have several working schemas. I tried...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found