微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在猫鼬中加入 3 个集合

如何解决如何在猫鼬中加入 3 个集合

课程模式

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 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?