简体   繁体   中英

Using PassportJS LocalStrategy in Node.js and trying to create a User object

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?

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 (ie schema), and then make use of it like so:

var user = app.db.models.User.findOne( {...})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM