I have the following document in my DB :

```
{
....
"key": "val1",
....
"array" :[
{
"k":"v1",
"rejected":"0"

},
{
"k":"v2",
"rejected":"0"

}

]
.....
}

```

***Now basically I want to set "rejected":"1" for ("key":"val1" && array[i]."k":"v1" ).***

The API call that I have written is :

```
var val1="val1";
var v1="v1";

    request.put('https://api.mlab.com/api/1/databases/DB/collections/doc?q={"key": "'+val1+'","array.k":"'+v1+'"}&apiKey=.....',
                        { json: { "$set": {"rejected": "1"}
                        } },
                        function (error, response, body) {
                            if (!error && response.statusCode == 200) {
                                console.log("----->Insertion"+body);
                                return res.status(200).send("[{\"status\":\"success\"}]");
                            }
                            else
                            {console.log(JSON.stringify(response));}
                        });

```

But the API instead of editing the needed field,it appends a new field at the end of document:

```
 {
    ....
    "key": "val1",
    ....
    "array" :[
    {
    "k":"v1",
    "rejected":"0"

    },
    {
    "k":"v2",
    "rejected":"0"

    }

    ]
    .....

    "rejected":"1"
    }

```