问题描述
课程模式
const courseSchema = new mongoose.Schema(
{
name: {
type: String,trim: true,required: 'Course name is required'
},logo: {
type: String,default: ""
},about: {
type: String,required: 'Please fill in course description'
},prerequisites: {
type: [String],required: 'Course must have prerequisite info',validation: {validator: (prerequisite) => prerequisite.length,message: 'Course must have prerequisite info'}
},materials:{
type: [String],required: 'Course must have materials info',validation: {validator: (materials) => materials.length,message: 'Course must have materials info'}
},price: {
type: Number,required: 'Course should have price,input 0 for free courses',validation: {validator: (price)=>price>=0,message: 'Price should not be less than 0'}
},rating: {
type: Number,default: 0
},countReview:{
type : Number,default : 0
},instructors: [{type: ObjectId,ref: "User"}],participants: [{ type: ObjectId,posts: [{type: ObjectId,ref: "Post"}],creator: {type: ObjectId,ref: "User"},syllabus : [{
title : {type: String,trim: true},description : {type : String,trim : true},date : {type : Date}
}],accessibility: {type: String,enum: ['private','public','protected'],default: 'private'}
},{timestamps: true}
)
强文本
const userSchema = new mongoose.Schema({
email: {
type: String,lowercase: true,unique: true,required: "Email is required",validate: {
validator: emailValidator,message: props => `${props.value} is not a valid email!`
}
},otp: {type: String,otpValidUntil: {type: Date},active: {type: Boolean,default: false},name: {
type: String,required: "Name is required",validate: {
validator: (v) => {
return (v.length > 4 && v.length < 15)
},message: props => `${props.value} should be > 4 and <15 chars`
}
},avatar: {
type: String
},about: {
type: String,default: ""
},linkedIn: {
type: String,isAnorganization: {
type: Boolean,default: false,required: "Organization field is required"
},isAnInstructor: {
type: Boolean,required: "IsAnIstructor field is required"
},teachers: [
{
type: ObjectId,ref: "User"
}
]
},
付款
const paymentSchema = new Schema(
{ 付款号码:{ 类型:字符串, 默认: '', // required : "需要支付号码" },xendit_id:{ 类型:字符串, 默认: '', },用户:{type:ObjectId,参考:“用户”}, 课程:{类型:ObjectId,参考:'课程'}, 发票网址:{ 类型:字符串, 默认 : '', // required : "发票 URL 是必需的" },地位 : { 类型:字符串, 枚举:["PENDING","PAID","SETTLED","EXPIRED"],默认值:'待定', // 必需:“需要状态” },blob_响应:{ 类型:字符串, 默认 : '', // 必需:“需要 Blob 响应” },外部 ID:{ 类型:字符串, 默认 : '', // 必需:“需要外部 ID” },到期日 : { 类型:字符串, 默认 : '', // 必需:“需要截止日期” } },{时间戳:真} )
如何像这样预览数据
[
{ “_ID”: { "$oid": "60afb96f8a734f2f5c1b4f05" },"name": "学习反应!",“参与者”:[ { “_ID”: { "$oid": "60c946416310f0721222c3d9" },"name": "Silcer L","email": "sssilacer@gmail.com",“彭巴亚兰”:[ [ { "状态": "已付款",“课程”: { "$oid": "60afb96f8a734f2f5c1b4f05" },“创建于”:{ "$date": "2021-06-16T01:07:35.938Z" } } ] ] },{ “_ID”: { "$oid": "60bcf8e4cc36555c6df57792" },"name": "六七","email": "six@gmail.com",“创建于”:{ "$date": "2021-06-09T12:21:31.988Z" } } ] ] },
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)