Encountering the error: TypeError: friendData.insert is not a function. Need assistance desperately. I've tried modifying the methods, which resulted in successful drops. Feeling helpless and clueless on how to proceed further with this issue.
const FriendSchema = new Schema({
user: {type: Schema.Types.ObjectId, ref: 'User'},
email: {type: String, unique: true, required: true},
friends: {type: Array},
subscribe: {type: Array},
requestFrineds: {type: Array},
})
module.exports = model('Friends', FriendSchema);
class friendService {
async addFriend(email, sender) {
const friendData = await FriendModel.findOne({email: email})
const senderData = await FriendModel.findOne({email: sender})
console.log(friendData, senderData)
await friendData.insert({requestFriends: sender});
await senderData.insert({subscribe: email});
friendData.save();
senderData.save();
// return friends;
}