Imagine this item (written with Ruby literally) in a MongoDB:
"text" > {"tag" = & gt; ["Foo", "Bar"], "Jobs" = & gt; [{"Title" = & gt; "Chief ass renghler", "tag" = & gt; Now, I want to search for items based on the tags at the first level of data, second I do not have a question like this (Ruby MongoDB Library. You can write: things.find ("tag" => gt; {"$ exists" => "foo"})
This will clearly offset the first example, but it will also match an example like this:
{"tag" => ["Falcon", "bar"], "jobs" = & gt; [{"Title" = & gt; "Trainee ass wrangler", "tag" = & gt; ["Assholes", "foo"]}]}
How can I ensure that I am only looking for the top level key? I am interested in getting answers in both javascript, ruby and a language-agnostic, because I want to use MongoDB as a cross-language store.
Obviously, I could pass a map - I'm trying to get stuff, but I am interested in seeing whether it is supported at a higher level (and as often as I am using Javascript I spend the map-reducing tasks!)
Actually, the query that you specify Will not match the second example. To match the second example, you will do this:
things.find ({"jobs.tags" => Foo "}) < P> The query selector is not a recursive app.