52

次の構造で Passport プロファイルを検証して保存しようとしています。

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

これは私が思いついたスキームです:

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

電子メールには「タイプ」と呼ばれるプロパティがあり、マングース タイプ用に予約されています。これを解決するにはどうすればよいですか?

4

1 に答える 1

131

オブジェクトを使用してフィールドを定義する必要があります。

type: {type: String}
于 2013-02-26T21:51:19.427 に答える