0

Inside the LocalStrategy function I am trying to create a new user that I can pass-back with:

var newUser = new User();

and I am getting this error

TypeError:  object is not a function 

I can't seem to find the what has the definition for User()

Any ideas?

laggingreflex
  • 32,948
  • 35
  • 141
  • 196
Pob Livsig
  • 95
  • 1
  • 9

1 Answers1

1

passport has no definition for User, per se. It sounds to me as if you might want to make use of a schema or similar kind of model.

For example, if your back-end is based on MongoDB, the mongoose project offers schema definitions, amongst other things. With mongoose you can set up a User object definition (i.e. schema), and then make use of it like so:

var user = app.db.models.User.findOne( {...})
Ben
  • 7,548
  • 31
  • 45
  • Thank you for your answer. I thought that that may be the case. The problem I have with this is that I am using MySQL. – Pob Livsig Dec 19 '14 at 02:58
  • @PobLivsig Ah OK. So do you have an existing schema defined in MySQL? Is there a `User` definition you can then work with, perhaps with an ORM tool like bookshelf? See http://stackoverflow.com/questions/15077700/using-existing-mysql-schema-in-nodejs and http://stackoverflow.com/questions/6007353/which-orm-should-i-use-for-node-js-and-mysql – Ben Dec 19 '14 at 09:46
  • I had never heard of an ORM before. Thank you very much. I will take a look at the ORMs and take another look at how much time Mongo would take to learn and then make a decision. Thank you again. I have learnt a lot. – Pob Livsig Jan 15 '15 at 12:50