2016-02-28 38 views
-4

我使用moongose與express.jsMoongose架構中的node.js

var mongoose = require('mongoose'); 

var UserSchema = new Schema({ //error 
    name: { 
     type: String 
    }, 
    email: { 
     type: String 
    }, 
    password: { 
     type: String 
    } 
}); 

有上面代碼中的錯誤沒有定義。我不知道什麼是錯的..

回答

1

你忘了定義Schema對象:

var mongoose = require('mongoose'); 
var Schema = mongoose.Schema; // <-- you forgot to define it here 

var UserSchema = new Schema({ 
    name: { 
     type: String 
    }, 
    email: { 
     type: String 
    }, 
    password: { 
     type: String 
    } 
});