2017-01-13 2 views
0

내가 무한 중첩에 대한 몽구스 중첩 된 스키마를 만들Mongoose에서 어떻게 스키마를 중첩시킬 수 있습니까?

같은 :

var workstructureSchema = new mongoose.Schema({ 

    title : String, 
    created_at:{type:Date, default : Date.now}, 
    deleted_at:Date, 
    subTitles:[structureSchema], 
    projectId : {type:ObjectId,ref : "Project"}, 
    locationId : {type: ObjectId, ref: 'Location'}, 
    workSpaceId : {type: ObjectId, ref: 'WorkSpace'}, 
    editor : {type: ObjectId, ref: 'Employee'}, 
    isDelete : {type:Boolean, default : false}, 

    }); 

    var structureSchema = new mongoose.Schema({ 
    childrensTitle:String, 
    grandChildrens: [String] 
    }); 

여기서 제목은 루트 자막 어린이 subsubtitiles 어린이입니다 .... N

에 간다 제발 도와주세요 !! !!

var workstructureSchema = new mongoose.Schema({ 

    title : String, 
    created_at:{type:Date, default : Date.now}, 
    deleted_at:Date, 
    subTitles: [{ type: Schema.ObjectId, ref: 'workstructureSchema (dont know how you called it)' }], 
    projectId : {type:ObjectId,ref : "Project"}, 
    locationId : {type: ObjectId, ref: 'Location'}, 
    workSpaceId : {type: ObjectId, ref: 'WorkSpace'}, 
    editor : {type: ObjectId, ref: 'Employee'}, 
    isDelete : {type:Boolean, default : false}, 

    }); 

당신이 workstructure 다른 workstructure etc..etc..etc 포함 할 수 자막에 workstructure (들)을 추가 할 수 있습니다이 방법을 ... :

답변

1

당신은처럼 스키마를 참조 할 필요가

희망이 있습니다.

+0

정말 고마워요. –

관련 문제