Page 370 - Nodejs 교과서 개정2판
P. 370

comment:	String,
           		createdAt:	{
           				type:	Date,
           				default:	Date.now,
           		},
           });


           module.exports	=	mongoose.model('User',	userSchema);




         ކҳझ ݽٕীࢲ Schema ࢤࢿ੗ܳ ࢎਊ೧ झః݃ܳ ٟ݅פ׮  द௬ۄ੉ૉীࢲ ݽ؛ਸ ੿੄ೞח Ѫҗ ࠺त೤פ׮
           ೙٘ܳ пп ੿੄೤פ׮


         ކҳझח ঌইࢲ _idܳ ӝࠄ ః۽ ࢤࢿೞ޲۽ _id ೙٘ח ੸য઴ ೙ਃо হणפ׮  աݠ૑ ೙٘੄ झಖ݅ ੑ۱೤
         פ׮


         ކҳझ झః݃ীࢲ ౠ੉ೠ ੼਷ String  Number  Date  Buffer  Boolean  Mixed  ObjectId  Arrayܳ чਵ۽ о
         ૕ ࣻ ੓׮ח ੼ੑפ׮  ކҊ٣࠺੄ ੗ܐഋҗ ઑӘ ׮ܰݴ  ಞ੄ܳ ਤ೧ ઙܨ ࣻܳ ઴ৈف঻णפ׮


         name ೙٘੄ ੗ܐഋ਷ String੉Ҋ ೙ࣻ੉ݴ Ҋਬೠ ч੉যঠ ೤פ׮  age ೙٘ח Number ੗ܐഋ੉Ҋ ೙ࣻ੉ݴ
         married ೙٘ח ࠛ ч ੗ܐഋ੉Ҋ ೙ࣻੑפ׮  comment ೙٘ח String ੗ܐഋੑפ׮  requiredա default ١

         ੄ ২࣌੉ ೙ਃೞ૑ ঋ׮ݶ рױೞѱ ੗ܐഋ݅ ݺदೞݶ ؾפ׮  createdAt ೙٘ח Date ੗ܐഋ੉Ҋ ӝࠄч਷ D
         ate.now ؘ੉ఠ ࢤࢿ ׼द੄ दр ੑפ׮


         ݃૑݄ীח ކҳझ੄ model ݫࢲ٘۽ झః݃৬ ކҊ٣࠺ ஸ۩࣌ਸ োѾೞח ݽ؛ਸ ٟ݅פ׮

         ؆Ӗ झః݃ب ٜ݅যࠇद׮


          schemas/comment.js
           const	mongoose	=	require('mongoose');


           const	{	Schema	}	=	mongoose;
           const	{	Types:	{	ObjectId	}	}	=	Schema;
           const	commentSchema	=	new	Schema({
           		commenter:	{
           				type:	ObjectId,
           				required:	true,
           				ref:	'User',
           		},
           		comment:	{
           				type:	String,
           				required:	true,
           		},
           		createdAt:	{
   365   366   367   368   369   370   371   372   373   374   375