Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Query with In on a int-array
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  17 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
TM  
View profile  
 More options Jun 19 2012, 4:53 am
From: TM <protel...@googlemail.com>
Date: Tue, 19 Jun 2012 01:53:38 -0700 (PDT)
Local: Tues, Jun 19 2012 4:53 am
Subject: Query with In on a int-array
Hi,

I have a document like this in mongo:

{
  "Acc" : [1],
  "_id" : 1005

}

With Query I could do something like this :

Query.In("Acc", accommodationTypeIds.Select(a => new BsonInt32(a))

where accommodationTypeIds is a List<int>.

I'm trying to do something like this with the QueryBuilder but I'm
stucked.

I tried something like

ElemMatch(a => a.AccomodationIds, q => q.In(c => c,
accommodationTypeIds))

but this doesn't work.

Could you help me with this?

Greets


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
craiggwilson  
View profile  
 More options Jun 19 2012, 10:06 am
From: craiggwilson <craiggwil...@gmail.com>
Date: Tue, 19 Jun 2012 07:06:28 -0700 (PDT)
Local: Tues, Jun 19 2012 10:06 am
Subject: Re: Query with In on a int-array

What version of the driver are you using?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TM  
View profile  
 More options Jun 19 2012, 11:16 am
From: TM <protel...@googlemail.com>
Date: Tue, 19 Jun 2012 08:16:03 -0700 (PDT)
Local: Tues, Jun 19 2012 11:16 am
Subject: Re: Query with In on a int-array
I think I have the latest version :
Revision: 038ec795c6dd69546d7f6a2f09dcf7b909958330
Author: rstam
Date: 15.06.2012 23:16:41

On 19 Jun., 16:06, craiggwilson <craiggwil...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
craiggwilson  
View profile  
 More options Jun 19 2012, 4:34 pm
From: craiggwilson <craiggwil...@gmail.com>
Date: Tue, 19 Jun 2012 13:34:00 -0700 (PDT)
Subject: Re: Query with In on a int-array

Wow, you are on the bleeding edge.  What is in master hasn't yet been
released.  It turns out that this not being possible is an oversight that
will get fixed before releasing.  We'll also scan for other areas that are
like this.  

Thanks for the report.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Stam  
View profile  
 More options Jun 19 2012, 4:37 pm
From: Robert Stam <rob...@10gen.com>
Date: Tue, 19 Jun 2012 16:37:29 -0400
Local: Tues, Jun 19 2012 4:37 pm
Subject: Re: [mongodb-csharp] Re: Query with In on a int-array

Or is there some general solution that turns arrays into scalars for
purposes of constructing these queries?

I know this isn't legal C#, but this is the idea:

Query<User>.EQ(x => x.AccomodationIds[*], 1) // where * represents any
element

On Tue, Jun 19, 2012 at 4:34 PM, craiggwilson <craiggwil...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
craiggwilson  
View profile  
 More options Jun 19 2012, 4:47 pm
From: craiggwilson <craiggwil...@gmail.com>
Date: Tue, 19 Jun 2012 13:47:14 -0700 (PDT)
Local: Tues, Jun 19 2012 4:47 pm
Subject: Re: [mongodb-csharp] Re: Query with In on a int-array

We'd have to support that in the BsonSerializationInfoFinder...  Which we
can do, but then it would look kinda weird.  Your [*] would be .First() or
.Single()...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Stam  
View profile  
 More options Jun 19 2012, 4:57 pm
From: Robert Stam <rob...@10gen.com>
Date: Tue, 19 Jun 2012 16:57:11 -0400
Local: Tues, Jun 19 2012 4:57 pm
Subject: Re: [mongodb-csharp] Re: Query with In on a int-array

More like .OneOf()

which we would have to define. First or Single don't sound right, they
already have defined meanings.

On Tue, Jun 19, 2012 at 4:47 PM, craiggwilson <craiggwil...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
craiggwilson  
View profile  
 More options Jun 19 2012, 5:03 pm
From: craiggwilson <craiggwil...@gmail.com>
Date: Tue, 19 Jun 2012 14:03:29 -0700 (PDT)
Local: Tues, Jun 19 2012 5:03 pm
Subject: Re: [mongodb-csharp] Re: Query with In on a int-array

Agreed...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Stam  
View profile  
 More options Jun 19 2012, 5:19 pm
From: Robert Stam <rob...@10gen.com>
Date: Tue, 19 Jun 2012 17:19:09 -0400
Local: Tues, Jun 19 2012 5:19 pm
Subject: Re: [mongodb-csharp] Re: Query with In on a int-array

Man, MongoDB's handling of array fields in queries is really confusing me.
I always thought that when the target field was an array that the document
would match if any of the array elements matched. But apparently that's not
always true:

> db.test.find()

{ "_id" : ObjectId("4fe0ebac8ee0adc8c442fa02"), "colors" : [ "blue",
"black" ] }
{ "_id" : ObjectId("4fe0ebbd8ee0adc8c442fa03"), "colors" : [ "yellow",
"orange", "red" ] }

> db.test.find({colors:{$ne:"red"}})

{ "_id" : ObjectId("4fe0ebac8ee0adc8c442fa02"), "colors" : [ "blue",
"black" ] }


Looks like $ne at least is handled specially. I thought this would match
both documents, since both of them have some value that is $ne to "red".

On Tue, Jun 19, 2012 at 5:03 PM, craiggwilson <craiggwil...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Hosted mongodb on azure?" by Daniel Harman
Daniel Harman  
View profile  
 More options Jun 20 2012, 2:24 pm
From: Daniel Harman <daniel.a.har...@gmail.com>
Date: Wed, 20 Jun 2012 19:24:49 +0100
Local: Wed, Jun 20 2012 2:24 pm
Subject: Hosted mongodb on azure?
Hi all,

Is there any new info on mongo as a service on the new azure? I saw some references to 10gen having a new service offering in the microsoft announcements a couple of weeks ago, but haven't found any new info on my searches?

I like the look of new azure, but want to avoid self hosting. I know app harbor all geared up with mongohq and the other competitor already integrated as services.

Dan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sridhar  
View profile  
 More options Jun 20 2012, 7:53 pm
From: sridhar <srid...@10gen.com>
Date: Wed, 20 Jun 2012 16:53:29 -0700 (PDT)
Local: Wed, Jun 20 2012 7:53 pm
Subject: Re: Hosted mongodb on azure?

Please create a new thread when the question is on a different subject

What we announced as part of the "Meet Windows Azure" event was the MongoDB
Installer for Windows Azure Virtual Machines (
http://www.mongodb.org/display/DOCS/MongoDB+Installer+for+Windows+Azure).
We are working to make the process for installing/using/managing MongoDB on
Windows Azure easier and more automated and the installer is the first in
the tool chest.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Harman  
View profile  
 More options Jun 21 2012, 9:27 am
From: Daniel Harman <daniel.a.har...@gmail.com>
Date: Thu, 21 Jun 2012 14:27:13 +0100
Local: Thurs, Jun 21 2012 9:27 am
Subject: Re: [mongodb-csharp] Re: Hosted mongodb on azure?

How does threading work on this forum? I changed subject and removed any visible content from the previous message as was most convenient on an iPad.  Very surprised it has threaded this together.

I'm still on iPad so no idea how to dethread given your reply also been threaded in.

Dan

Sent from my iPad

On 21 Jun 2012, at 00:53, sridhar <srid...@10gen.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
craiggwilson  
View profile  
 More options Jun 21 2012, 9:32 am
From: craiggwilson <craiggwil...@gmail.com>
Date: Thu, 21 Jun 2012 06:32:54 -0700 (PDT)
Local: Thurs, Jun 21 2012 9:32 am
Subject: Re: [mongodb-csharp] Re: Hosted mongodb on azure?

Instead of posting a reply (removing content and changing subject), you
would just create a new topic.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Stam  
View profile  
 More options Jun 21 2012, 9:33 am
From: Robert Stam <rob...@10gen.com>
Date: Thu, 21 Jun 2012 09:33:18 -0400
Local: Thurs, Jun 21 2012 9:33 am
Subject: Re: [mongodb-csharp] Re: Hosted mongodb on azure?

To start a new thread just send a brand new email to
mongodb-csharp@googlegroups.com instead of replying to an existing one. Or
create a new post using the Google Groups web interface.

Hitting reply and clearing the subject line and content area isn't enough.
There must be something preserved in the email headers that keeps it tied
to the original thread.

On Thu, Jun 21, 2012 at 9:27 AM, Daniel Harman <daniel.a.har...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Query with In on a int-array" by craiggwilson
craiggwilson  
View profile  
 More options Jun 21 2012, 9:34 am
From: craiggwilson <craiggwil...@gmail.com>
Date: Thu, 21 Jun 2012 06:34:02 -0700 (PDT)
Local: Thurs, Jun 21 2012 9:34 am
Subject: Re: [mongodb-csharp] Re: Query with In on a int-array

@TM: We have pushed a new commit to master that should contain the code you
need to do handle your situation.  If you have some time, would you mind
pulling the latest and verifying it fixes your issue.  Thanks...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TM  
View profile   Translate to Translated (View Original)
 More options Jul 10 2012, 11:13 am
From: TM <protel...@googlemail.com>
Date: Tue, 10 Jul 2012 08:13:30 -0700 (PDT)
Local: Tues, Jul 10 2012 11:13 am
Subject: Re: [mongodb-csharp] Re: Query with In on a int-array

Sorry for the late response. I just pulled the last version and will run
some tests, but the syntax looks clean now.

In this context a have another question:

How would I do this with the QueryBuilder?

Query.EQ("Access._id", 4711)

I could use ElemMatch, but this doesn't feel right here. My object looks
something like this:

{ "_id" : 5,
"Access":[{"_id":4711}, {"_id": 4712}]

}

Greets

Am Donnerstag, 21. Juni 2012 15:34:02 UTC+2 schrieb craiggwilson:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
craiggwilson  
View profile  
 More options Jul 10 2012, 11:59 am
From: craiggwilson <craiggwil...@gmail.com>
Date: Tue, 10 Jul 2012 08:59:23 -0700 (PDT)
Local: Tues, Jul 10 2012 11:59 am
Subject: Re: [mongodb-csharp] Re: Query with In on a int-array

Yes, you'll need an elemMatch for this.  It would be awkward to do this in
the a typed api as it would require getting a single element out of a list
(Query<MyClass>.EQ(mc => mc.Access.Single().Id, 4712).  Anyways, we don't
currently support this via the typed api. If elemMatch isn't what you want
here, you'll need to use the untyped query api.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »