is to create a data table of contacts, and then the front end searches the corresponding friends through its own username and traverses to the page
this is my mongoose schema
var contactSchema = new Schema({
user1:{
type:Object,
required:true
},
user2:{
type:Object,
required:true
},
created_time:{
type:String,
default: () => moment(new Date()).format("YYYY-MM-DD")
},
},
{
versionKey: false
})
this is the interface for Node.js to store data
router.post("/agree/apply",function(req,res,next){
console.log(req.body)
new Contact({
}).save(function(error,result){
if(error){
console.log(error)
}
//console.log(result)
res.json("yes")
})
})
I want to save user1name user1photo and user2name user2photo to the data table, how to write schema. Then how to write the conditions when querying the data, that is, to obtain username and photo in addition to the conditions (their own username)