I just discovered this now and its kinda annoying for me. I want to
exclude dates from this subcollections:
> db.events.findOne(null, {_id:1, Name:1, "Locations":1 })
{
"_id" : ObjectId("4cbc7344b4a5ef111c1a3c6a"),
"Name" : "Bar Crawl",
"Locations" : {
"_t" :
"System.Collections.Generic.List`1[[Wunderman.EventRSVPSite.BusinessObjects.EventLocation,
EventRSVPSite.BusinessObjects]]",
"v" : [
{
"_id" :
ObjectId("4cbc7345b4a5ef111c1a3c6b"),
"Name" : "McSorley's Olde Ale House",
"Address1" : "15 East 7th Street",
"Address2" : null,
"City" : "New York",
"State" : "NY",
"Zip" : "10003",
"Capacity" : 0,
"Dates" : {
"_t" :
"System.Collections.Generic.List`1[[Wunderman.EventRSVPSite.BusinessObjects.EventDate,
EventRSVPSite.BusinessObjects]]",
"v" : [ ]
}
},
{
"_id" :
ObjectId("4cbc7345b4a5ef111c1a3c6c"),
"Name" : "O'Keefe's Bar & Grill",
"Address1" : "62 Court St",
"Address2" : null,
"City" : "Brooklyn",
"State" : "NY",
"Zip" : "11201",
"Capacity" : 0,
"Dates" : {
"_t" :
"System.Collections.Generic.List`1[[Wunderman.EventRSVPSite.BusinessObjects.EventDate,
EventRSVPSite.BusinessObjects]]",
"v" : [ ]
}
}
]
}
}
So I tried this:
> db.events.findOne(null, {_id:1, Name:1, "Locations":1, "Locations.v.Dates": 0})
Mon Oct 18 12:23:27 uncaught exception: error {
"$err" : "You cannot currently mix including and excluding
fields. Contact us if this is an issue.",
"code" : 10053
}
Now I get the same results from:
db.events.findOne(null, {_id:1, Name:1, "Locations._t":1,
"
Locations.v.Name":1, "Locations.v.Address1":1, "Locations.v.Address2":
1, "Locations.v.City":1, "Locations.v.State":1,"Locations.v.Zip":1 })
However, if the first form worked, it would be more readable.
Justin
On Oct 13, 9:43 am, Eliot Horowitz <
eliothorow...@gmail.com> wrote:
> What version are you on?
> I think that was a change for 1.6
>
>
>
> On Wed, Oct 13, 2010 at 8:57 AM, michael Baarz <
mba...@gmail.com> wrote:
> > Hello,
>
> > i have found the following info in the Definitive MongoDB Guide:
>
> > You can also use this second parameter toexcludespecific key/value
> > pairs from the
> > results of a query. For instance, you may have documents with a
> > variety ofkeys, and
> > the only thing you know is that you never want to return the
> > "fatal_weakness" key:
> >> db.users.find({}, {"fatal_weakness" : 0})
> > This can even prevent "_id" from being returned:
> >> db.users.find({}, {"username" : 1, "_id" : 0})
> > {
> > "username" : "joe",
> > }
>
> > This is very nice i dont wanna the _id value. Now do something similar
> > in my mongodb:
>
> >> db.custs_struct.find({pid:4},{cid:1, "_id":0})
> > error: {
> > "$err" : "You cannot currently mix including and excluding fields.
> > Contact us if this is an issue."
> > }
>
> > Is it a bug, or a feature? How toexcludethe _id value now from the