Reputation: 377
I insert everytime in mongo db a field like {text:data.text,userId:'5454234ddsc32fcsd23dsdfe3'}
.After i insert more fields like this one remains ok,and the rest of all are null.What should i do?I think mongo see this like a duplicate.I thinks i should allow duplicates.Here is my schema.
var ConversationsSchema=new Schema({
conversations:{type:Array,
text:String,
sender:String,
to:String,
userId:{type:String,select:true,unique:false}
}
})
Update query:
Conversations.update(({_id:data.conversationID},{$addToSet:{conversations:{text:data.textMessage,sender:data.sender,to:data.to,userId:data.userId}}}),function(err){
//console.log('Cannot update your conversation')
console.log(err);
})
Thanks for any help!
Upvotes: 1
Views: 108
Reputation: 377
Update! Schema must be:
var ConversationsSchema=new Schema({
conversations:{type:Array,
text:String,
sender:String,
to:String,
userId:{type:String,select:true,index:{unique:false}}
}})
Upvotes: 1