As you see there is a seeds array.What i am trying to do is check seeds array,if it has the object with given ObjectId,then increment count else Insert a new Object with Id and count 1
I would sort of start with something like this, not sure if you can do it in one operation, and check the response on item on update and non-update, not sure if that if statement is correct.
If there are many farms with many seeds, the DB structure is not too efficient. You would rather keep a collection for seeds indexed by farmId and ownerId, beside the farms collection, something like below. MongoDB (and NoSQL) prefers, in your case, to keep two perspectives: farms and farm on the seeds in order to avail of the incredible query speeds of NoSQL.: