I am trying to achieve an upsert with push in Laravel using MongoDB. Basically, I am saving the number of likes from a YouTube post. If the record already exists, I would like to push to an array called 'history'; otherwise, I would like to create the record with all the post details.
Does anyone have any idea how I can achieve this?
I am using this package for the connection with MongoDB. https://github.com/jenssegers/laravel-mongodb/
Thanks.
This is what I want to achieve more precisely: https://user-images.githubusercontent.com/44676430/154502252-0c3dcef4-9bdd-49ae-86fd-3076bc37bbc7.png