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
get size of 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
  5 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
 
Earthson  
View profile  
 More options Apr 22 2012, 9:09 am
From: Earthson <earthson.la...@gmail.com>
Date: Sun, 22 Apr 2012 21:09:24 +0800
Local: Sun, Apr 22 2012 9:09 am
Subject: get size of array?

for document {'a':(1,2,3), '_id':Object(xxxx...)}, how could I get the size
of 'a'.
I do not find a way to do this, someone help~

--

Perfection is achieved
not when there is nothing more to add
 but when there is nothing left to take away


 
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.
Scott Hernandez  
View profile  
 More options Apr 22 2012, 9:53 am
From: Scott Hernandez <scotthernan...@gmail.com>
Date: Sun, 22 Apr 2012 06:53:11 -0700
Local: Sun, Apr 22 2012 9:53 am
Subject: Re: [mongodb-user] get size of array?
You need to do this at the client/app.

In the mongo javascript shell you can do this: doc.a.length

You may also want to look at the query operators:
http://mongodb.org/display/DOCS/Advanced+Queries


 
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.
Asoka Sampath Edussooriya  
View profile  
 More options Apr 22 2012, 9:58 am
From: Asoka Sampath Edussooriya <eas...@gmail.com>
Date: Sun, 22 Apr 2012 19:28:32 +0530
Local: Sun, Apr 22 2012 9:58 am
Subject: Re: [mongodb-user] get size of array?

I am not sure about the exact way of getting the size or length of the
array. but this is similar what you asking.

db.collection.find({a:{$size:3}});

this will match document which has the array size of 3

Thanks!

--
Asoka Sampath Edussooriya

 
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.
Earthson  
View profile  
 More options Apr 22 2012, 10:38 am
From: Earthson <earthson.la...@gmail.com>
Date: Sun, 22 Apr 2012 22:38:50 +0800
Local: Sun, Apr 22 2012 10:38 am
Subject: Re: [mongodb-user] get size of array?

May be I should add an extra field to count the length(with limit
operations, not addToSet).
thx~

On Sun, Apr 22, 2012 at 9:58 PM, Asoka Sampath Edussooriya <eas...@gmail.com

--

Perfection is achieved
not when there is nothing more to add
 but when there is nothing left to take away


 
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.
Scott Hernandez  
View profile  
 More options Apr 22 2012, 10:45 am
From: Scott Hernandez <scotthernan...@gmail.com>
Date: Sun, 22 Apr 2012 07:45:17 -0700
Local: Sun, Apr 22 2012 10:45 am
Subject: Re: [mongodb-user] get size of array?
If you need to do queries on it with an index, then yes.


 
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 »