I can't recall the name but mongoDB allows you to find by looking at arrays
values, but it will always return the whole document I think you'll have to
add the logic to return the part of the document you're interested in.
On Monday, July 20, 2015 at 12:25:13 PM UTC-3, Satish B wrote:
>
> Document:
> *User *collection
>
>> {
>> 'name': 'abc',
>> "watch" : [
>> {
>> "cat_name" : "Satish",
>> "cat_id" : "55ace5047f80b77017edsfa0e",
>> "script" : {
>> "script" : "SBIN",
>> "exchange" : "NS"
>> }
>> },
>> {
>> "cat_name" : "Satish",
>> "cat_id" : "55ace5047f8sdf7017ed8a0e",
>> "script" : {
>> "script" : "ITC",
>> "exchange" : "NS"
>> }
>> },
>> {
>> "cat_name" : "technotip",
>> "cat_id" : "55ace590htt0b77017ed8a10",
>> "script" : {
>> "script" : "SYNCOM",
>> "exchange" : "NS"
>> }
>> }
>> ]
>> }
>>
>
> Now how can I fetch only the object cat_name = technotip
>
> User.find({'name': 'abc'}, {});
> This gets me the whole document. I only want the object which is inside
> key 'watch', with 'cat_name' as ''technotip'.
>
> Please help.
>
>
> If I had simple values inside the array I would have used comparison
> operator <http://technotip.com/3031/comparison-operators-mongodb/> to
> fetch the value, but in this case I have objects inside the array.
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/f1b50b69-84f5-4f3a-adc3-71cc2dc04a60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.