Add items to embeded C#

Hi i have stucture looking like this:

id: *ObjectId*
name: "some name"
cards: []

In my model field cards are List<Cards> any idea how to push another card into it after “/addCard” endpoint?

I’m new in mongo ;/

Nevermind, I figured it out on my own.

            var filter = Builders<User>.Filter.Eq("Id", user.Id);
            var insert = Builders<User>.Update.AddToSet("cards", cardAdd.card);

I made update querry and then AddToSet called on cards

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.