MongoDB (Node.JS) Create, Append, and Update.
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I am looking to achieve the following operations with the MongoDB Node.JS driver, could this be performed with an optimal approach? There are three possible operations required: create, append, and update.

Create the following document:

{
    "_id": "hello_world_cluster",
        "items": [
            {
                "item_name": "my_item_one",
                "first_seen": 1000,
                "last_seen": 1000,
                "logic": true
            }
        ]
}

Append new items to an array:

{
    "_id": "hello_world_cluster",
        "array": [
            {
                "item_name": "my_item_one",
                "first_seen": 1000,
                "last_seen": 1000,
                "logic": true
            },
            {
                "item_name": "my_item_two",
                "first_seen": 2000,
                "last_seen": 2000,
                "logic": true
            },
            {
                "item_name": "my_item_three",
                "first_seen": 3000,
                "last_seen": 3000,
                "logic": true
            }
        ]
}

Update items that are found in an array:

    {
        "_id": "hello_world_cluster",
            "items": [
                {
                    "item_name": "my_item_one",
                    "first_seen": 1000,
                    "last_seen": 4000,
                    "logic": false
                },
                {
                    "item_name": "my_item_two",
                    "first_seen": 2000,
                    "last_seen": 2000,
                    "logic": true
                },
                {
                    "item_name": "my_item_three",
                    "first_seen": 3000,
                    "last_seen": 3000,
                    "logic": true
                }
            ]
    }
18 days ago

Crowdsource coding tasks.