Hey
I’m trying to follow this tutorial > https://blog.mlab.com/2018/09/use-push-to-insert-elements-into-an-array/
Mainly >
> db.alphabet.insert({
"_id": "22222",
"array": ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j']
})
// We missed the 'i'!
// Let's add it in the position before the last element.
> db.alphabet.update(
{ "_id": "22222" },
{
$push: {
array: {
$each: ['i'],
$position: -1
}
}
})
// Check the results:
> db.alphabet.find({ "_id": "22222" })
{ "array" : [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" ] }v
I’m trying to reproduce it in c++ but I’m lost… can any1 guide me somehow?
auto replace = coll.update_one(make_document(kvp("_id", bsoncxx::oid("5f3289b7807200001f002b35"))),
make_document(kvp("$push", make_document(
kvp("arrayKeyNameTest","eghhh????????????")
))));
Can any1 help out?
TIA