Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to add another schema id on mongodb

//first Schema
const user = new Schema({
	username:[type:String, unique:true]
})

//second Schema
const notes = new Schema({
	id : [{ type: Schema.Types.ObjectId, ref: 'user' }] // gets _id of first Schema(user)
  notes:[type:String, trim:true]
})
 
PREVIOUS NEXT
Tagged: #add #schema #id #mongodb
ADD COMMENT
Topic
Name
6+9 =