2013-02-26 20 views
26

staram się potwierdzić i zapisać profil Passport z tej struktury:mangusta pole z nazwą typu

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

Jest to schemat wymyśliłem:

// 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 
}); 

E -mail ma właściwość o nazwie "typ", która jest zarezerwowana dla typu mangusty. Jak rozwiązać ten problem?

Odpowiedz

73

Trzeba zdefiniowania pola przy użyciu obiektu:

type: {type: String} 
+0

Dzięki! Przyjmuję odpowiedź, gdy pozwala mi na to czas. Niepowiązane pytanie, tablica e-mail ma teraz pole _id, którego nie chcę. Czy istnieje również szybka/łatwa naprawa? –

+1

@RoelvanUden Zobacz odpowiedź na to pytanie: http://stackoverflow.com/questions/12617754/mongoose-js-3-how-to-tell-that-nested-is-not-a-document/12621311#12621311 – JohnnyHK