I have a collector module that pulls a remote API every 30 seconds. That gives me a list of objects that I insert or update in a MongoDB database.
{
"id" : "oulkhhvoiupokb",
"name" : "test1",
"status" : "OPEN"
},
{
"id" : "oulkhhvoisksbsjkkb",
"name" : "test2",
"status" : "CLOSED"
}
In fact, I only collect the objects that have the OPEN status. And with a loop, I set the rest of the object as CLOSED (because they are not OPEN). But in the future, it will take a lot of time because the amont of object will grow.
I work with Golang and MGO package.
Is there a way to do it faster and cleaner please ? Something like setting a basic field value for Mongo documents ?
To explain it differently, when I will insert the OPEN objects in the database, all the other ones that are already in database must be CLOSED. Can Mongo do it ?
Thanks.