ฉันสร้างแรกรูปแบบชุดสีและอีกหนึ่ง(2 ตาราง)ใน MongoDB เพื่อนบ้าน 2 แยกข้อมูล ตอนนี้คนแรกทำงานได้โดยไม่มีการท้าทายนะแต่คำที่สองชุดรูปแบบควรจะเป็นคนที่บ้านของผู้ใช้ข้อมูล
ตอนนี้ฉันมีปัญหาเรื่องโดนข้อมูลของผู้ใช้. ฉันไม่เหมือนจะเข้าใจปัญหาคืออะไร
ครูปแบบชุดสีดูเหมือนนี้
var db = require('../database');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var SubscriptionSchema = new Schema({
company_name : String,
company_address : String,
company_city : String,
company_state : String,
companyrep_name : String,
companyrep_email : String,
company_telnum : String,
company_zip : String,
company_website : String,
timezone : String,
company_logo : String,
company_country : String,
product_requested : String,
methodof_payment : String,
dateof_request : String,
dateof_expiry : String,
});
var endUserRegisterSchema = new Schema({
username : String,
company_name : String,
password : String,
fullname : String,
company_ccy: String,
company_timezone : String
})
module.exports = mongoose.model('Subscription',SubscriptionSchema);
module.exports = mongoose.model('Users',endUserRegisterSchema);
งั้นเพิ่มมันสำหรับเส้นทางมันควรจะมองแบบนี้
ที่ router ใน users.js ซึ่งมันควรจะต้องช่วยข้อมูลที่เป็นแบบนี้
router.post('/', function (req, res) {
var newReg = new Users();
newReg.username = req.body.username;
newReg.company_name = req.body.company_name;
newReg.password = req.body.password;
newReg.fullname = req.body.fullname;
newReg.save(function(err,Users){
if(err){
res.send('Error registering User');
}else{
res.send(Users);
}
});
});
งั้นบน app.js ผมแค่เพิ่มที่อยู่ URL ที่สัมพันธ์กัน
เพื่อเรียกดูที่เหลือรูปแบบ api. ทั้งหมดนี้ทำงานแต่ผมมีปัญหาเรื่องมันไม่ช่วย informtion มต้อง Mongo DB. ตอนที่ฉันขอผ่านเหมื LANGUAGE เหมือนนี้
{
"username":"admin@********.com",
"company_name":"blah blah blah",
"password":"supermna1",
"fullname":"Admin_blah blah"
}
ฉันกลับมาเข้าเรื่องเป็นการตอบสนมากกว่าที่เต็มไปด้วยข้อมูล
{
"_id": "619ddde9ff437222b17e888d",
"company_name": "blah blah blah",
"__v": 0
}
มีบางอย่างที่ผมไม่ได้ใช่มั้ย? ฉันคงต้องการรูปแบบของช่วยทำให้ชัดเจนอยู่ที่นี่