Recursive function - to get Children(might be parents too) of parents
output sample
|-- Child 1.1
|-- Child 1.1.1
|-- Child 1.1.2
|-- Child 1.1.2.1
|-- Child 1.1.3
|-- Child 1.1.3.1
|-- Child 1.2
Parent 2
|-- Child 2.1
|-- Child 2.1.1
|-- Child 2.1.2
|-- Child 2.1.2.1
|-- Child 2.1.3
|-- Child 2.1.3.1
|-- Child 2.1.3.1.1
|-- Child 2.2
|-- Child 2.3
db sample
/* 0 */
{
"_id" : "22",
"path" : "null",
"created" : ISODate("2014-08-22T06:40:55.790Z"),
"user_name" : "rajesh",
"user_id" : "H001",
"body" : "hh jj kk mm",
"thread_id" : "1001",
"thread_type" : "PHOTO"
}
/* 1 */
{
"_id" : "23",
"path" : "22",
"created" : ISODate("2014-08-22T06:43:17.072Z"),
"user_name" : "rajesh",
"user_id" : "H001",
"body" : "jjj",
"thread_id" : "1001",
"thread_type" : "PHOTO"
}
/* 2 */
{
"_id" : "24",
"path" : "null",
"created" : ISODate("2014-08-22T06:57:33.185Z"),
"user_name" : "rajesh",
"user_id" : "H001",
"body" : "jjjjj",
"thread_id" : "1001",
"thread_type" : "PHOTO"
}
/* 3 */
{
"_id" : "25",
"
"path" : "null",
"created" : ISODate("2014-08-22T07:00:27.978Z"),
"user_name" : "rajesh",
"user_id" : "H001",
"body" : "jjjjj",
"thread_id" : "1001",
"thread_type" : "PHOTO"
}
/* 4 */
{
"_id" : "26",
"path" : "24",
"created" : ISODate("2014-08-22T07:05:16.697Z"),
"user_name" : "rajesh",
"user_id" : "H001",
"body" : "kkkk",
"thread_id" : "1001",
"thread_type" : "PHOTO"
}
/* 5 */
{
"_id" : "27",
"path" : "25",
"created" : ISODate("2014-08-22T07:07:46.522Z"),
"user_name" : "rajesh",
"user_id" : "H001",
"body" : "hherr tthe",
"thread_id" : "1001",
"thread_type" : "PHOTO"
}
/* 6 */
{
"_id" : "28",
"path" : "null",
"created" : ISODate("2014-08-26T05:11:19.146Z"),
"user_name" : "rajesh",
"user_id" : "H001",
"body" : "kkk",
"thread_id" : "1009",
"thread_type" : "PHOTO"
}
/* 7 */
{
"_id" : "29",
"path" : "28",
"created" : ISODate("2014-08-22T06:43:23.072Z"),
"user_name" : "rajesh",
"user_id" : "H001",
"body" : "jjjjjjjjj",
"thread_id" : "1001",
"thread_type" : "PHOTO"
}
/* 8 */
{
"_id" : "30",
"path" : "null",
"created" : ISODate("2014-07-23T06:40:55.790Z"),
"user_name" : "rajesh",
"user_id" : "H001",
"body" : "hh jj kk mm",
"thread_id" : "1002",
"thread_type" : "PHOTO"
}
/* 9 */
{
"_id" : "31",
"path" : "null",
"created" : ISODate("2014-07-21T06:40:55.790Z"),
"user_name" : "rajesh",
"user_id" : "H001",
"body" : "hh jj kk mm",
"thread_id" : "1009",
"thread_type" : "PHOTO"
}