Answers for "F# mongodb insert to array"

0

F# mongodb insert to array

type FriendModel = {
        Name : string
        Phone : string
    }
    type PersonModel = {
        Name : string
        Friends: FriendModel list
    }

    let insertNewFriend (personName:string) (newFriend:FriendModel) = 
        let filter = Builders<PersonModel>.Filter.Eq((fun x -> x.Name), personName)
        let fields = StringFieldDefinition<PersonModel>("Friends")
        let updateDefinition = Builders<PersonModel>.Update.Push(fields,{Name="Mahdi";Phone="+1"})
        collections.UpdateOne(filter,updateDefinition)
Posted by: Guest on June-27-2020

Browse Popular Code Answers by Language