mongodb add to array if not exists
db.tags.update(
{name: 'sport'},
{$addToSet: { videoIDs: "34f54e34c" } }
);
mongodb add to array if not exists
db.tags.update(
{name: 'sport'},
{$addToSet: { videoIDs: "34f54e34c" } }
);
mongodb insert
db.products.insert( { item: "card", qty: 15 } )
insert item into list mongodb
db.col.update(
{ name: 'doc', 'list.id': 2 },
{$push: {'list.$.items': {id: 5, name: 'item5'}}}
)
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)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us