Flink-Mongodb Sink - How can i achieve below use c...
# troubleshooting
s
Flink-Mongodb Sink - How can i achieve below use case ? Please help..
Copy code
-- INSERT Only collection (This is possible using "UpdateOneModel" and it's working as expected.)
db.cid.findOneAndUpdate(
   { _id: { "userid": 1, "cid": 101} },
   [
   { $set: { updatedAt: new Date()} },
   { $set: { finishtype: { $concatArrays: [ [1001], { $ifNull: [{ $getField: "finishtype" }, []] }] }}},
   ],
   { upsert: true}
);



-- STUCK HERE
-- UPDATE from above collection (cid) to NEW collection (score)
db.cid.find({ _id: { "userid": 1, "cid": 101} }).forEach(
function (elem) {
    db.scores.updateOne(
        {
            _id: elem._id.userid
        },
        [
        { $set: { finishtype: { $slice: [ { $concatArrays: [ [ { $concatArrays: [[1002], { "$ifNull": [elem.finishtype, []] }  ] } ], { "$ifNull": [ { $getField: "finishtype" }, []] } ] }, 5 ] } } }
        ],
        { upsert: false}
    );
});