MongoDB
 sql >> Base de données >  >> NoSQL >> MongoDB

Champs supplémentaires pour l'enregistrement du compte passeport-local-mongoose ?

Passez simplement les champs de modèle requis en option.

var mongoose = require('mongoose'),
    passportLocalMongoose = require('passport-local-mongoose');

var userSchema = mongoose.Schema;
var User = new userSchema({
    username: ...,
    admin: ...,
    // Configure other schema fields
});

User.plugin(passportLocalMongoose, {
   selectFields : 'username admin etc' //Space seperate the required fields
);

Et lors de l'inscription,

// user_details contains all information required
// for registration such as username, password, admin, etc.
User.register(new User(user_details), user_password, cb);