The example is a very simplified one in order to show what is not
functioning...This discussion is not about whether doing such a thing
is a good idea. In fact example is intentionally trivial in order to
determine what is not working. My code is far more complex than the
example above. My problem is that the simplest example above is not
working so I have little hope for the rest of the complex logic to
function until this is understood and resolved.
I need to perform serve-side because I need a number of subqueries all
of which could be accessing 100's-1000 records against 100GB sampling
and I do not want to retrieve these documents back to the client in
order to execute 100's-1000 subsequent queries. Major waste of
network bandwidth and doing something procedurally that I know the
server can do optimally is better for performance.
My actual example uses $or of a number of $in clauses in order to
determine a list of things that I need to search for within another
very large collection. I might have 100 or more things in my initial
query that I need need to find within my other collection. Those 100
things EACH could be used within this other collection by 100's of
different documents, thus 100x100 records could be affected and I do
not want to bring this data back. Using server-side I can iterate the
first 100 and perform subsequent updates as needed using a server-side
function.
Thus I have something like db.things.find( {"complex conditions
here"} ).foreach( function( x) { "foreach x db.othercol.update( {},
{add to a number of subdoc arrays} ) " } )
Back to the issue at hand...The above is not working so it seems there
is an issue (most likely with the PHP driver). I was hoping to pose
the question in order to see if someone has had such experiences. It
may be the case I have stumbled upon a bug or maybe I am overlooking
something and have an error in my use of the drived.
Cheers