different collections and fetched the fields

52 views
Skip to first unread message

tiyyagur...@gmail.com

unread,
Nov 20, 2015, 11:26:59 AM11/20/15
to mongodb-user
hi ,

i have number of collections but i don't know how many fields in documents .I want fetch the particular field in every collection but i don't know how to fetch the fields in all collections.

Any one knows please share your ideas.


PFA,

 my task is,I have four collections and every collection so many fields is there,  how to fetch the "date" field in all collections at a time. .


Thanking you,

T.k.r    
collections.txt

Stephen Steneker

unread,
Nov 26, 2015, 11:26:02 PM11/26/15
to mongodb-user
Hi,

Can you share an example of the result you are trying to achieve given these four sample documents?

Thanks,
Stephen

kran...@mantena.in

unread,
Dec 18, 2015, 6:02:42 PM12/18/15
to mongodb-user
Hi,
    I want the output like this       db.one.insert({"createdDate":""})
                                               db.two.insert({"createdDate":"2-9-15",
                                                                  "interviewDate":"2-7-15"})
                                               db.three.insert({"createdDate":""}) 
                                               db.four.insert({"createdDate":""})
 here i don't know field names but i want where is Date included filed i want that field 

"This communication (including any accompanying documents) is intended only for the use of the addressee(s) and contains information that is PRIVILEGED AND CONFIDENTIAL. If you are not the intended recipient, you are hereby cautioned that any unauthorized reading, dissemination, distribution or copying of this communication is strictly prohibited and is unlawful. If you have received this communication in error, please notify us immediately by dialing 040 23125333 or email at le...@mantena.in and promptly destroy the original communication. Communicating through email is not secure and capable of interception, corruption and delays. Anyone communicating with Mantena Group Companies - Mantena Infra & Mantena Technologies Pvt Ltd by email accepts the risks of email communications and their consequence"

John De Goes

unread,
Dec 19, 2015, 4:13:16 PM12/19/15
to mongodb-user

First, the fact that you want to solve this problem... is probably a problem in and of itself!

But regardless, what you want to do requires two operators which do not presently exist: $unravel and $typeof.

The hypothetical $unravel operator can split up a document into key/value pairs. The even more hypothetical $typeof operator can allow you to match for values of the date type (note that you can emulate $typeof currently, but I'm not going to explain how as it's quite complicated and not useful without $unravel).

You can vote for $unravel here. In the meantime, you can achieve what you want through map/reduce, by writing appropriate Javascript to iterate over document values and emit the fields that have a type of date.

Regards,

John
Reply all
Reply to author
Forward
0 new messages