2013-02-26 17 views
26

Sto cercando di convalidare e salvare un profilo Passport con questa struttura:campo mangusta con il tipo di nome

http://passportjs.org/guide/profile/

Questo è lo schema mi si avvicinò con:

// Define the schema. 
schema = new mongoose.Schema({ 
    // The name of this user, suitable for display. 
    displayName: String, 
    // Each e-mail address ... 
    emails: [{ 
     // ... with the actual email address ... 
     value: String, 
     // ... and the type of email address (home, work, etc.). 
     type: String 
    }], 
    // A unique identifier for the user, as generated by the service provider. 
    id: String, 
    // The name ... 
    name: { 
     // ... with the family name of this user, or "last name" in most Western languages ... 
     familyName: String, 
     // ... with the given name of this user, or "first name" in most Western languages ... 
     givenName: String, 
     // ... and with the middle name of this user. 
     middleName: String 
    }, 
    // The provider which with the user authenticated. 
    provider: String 
}); 

L'e -mail ha una proprietà chiamata 'tipo', che è riservata per un tipo di mangusta. Come lo risolvo?

risposta

73

è necessario definire il campo con un oggetto:

type: {type: String} 
+0

Grazie! Accetterò la risposta quando il limite di tempo mi consentirà. Una domanda non correlata, l'array di posta elettronica ora ha un campo _id che non desidero. C'è anche una soluzione rapida/facile? –

+1

@RoelvanUden Vedere la risposta a questa domanda: http://stackoverflow.com/questions/12617754/mongoose-js-3-how-to-tell-that-nested-is-not-a-document/12621311#12621311 – JohnnyHK