On Apr 22, 2012, at 9:48, Cesar Cespedes Loayza <cche...@hotmail.com> wrote:
> Buenos días a todos, tengo un pequeño inconveniente, tengo un colección con
> muestro, y deseo crear una consulta que me muestre los datos como en el
> resultado.
> Intente de muchas formas formas, hasta con map-reduce pero no encuentro la
> solución.
>
>
> Colección
> {
> “_id” : “4da2c0e2e999fb56bf000002”,
> “nompap” : “papa1”,
> “hijos” : [
> {
> “_id” : “4da2c0e2e999fb56bf000003”,
> “nomhij” : "hijo1",
> },
> {
> “_id” : “4da2c0e2e999fb56bf000004”,
> “nomhij” : "hijo2",
> },
> {
> “_id” : “4da2c0e2e999fb56bf000005”,
> “nomhij” : "hijo3",
> }
> ]
> }
> {
> “_id” : “4da2c0e2e999fb56bf000006”,
> “nompap” : “papa2”,
> “hijos” : [
> {
> “_id” : “4da2c0e2e999fb56bf000007”,
> “nomhij” : "hijo21",
> },
> {
> “_id” : “4da2c0e2e999fb56bf000008”,
> “nomhij” : "hijo22",
> }
> ]
> }
>
>
> Resultado
> {“nompap” : “papa1”,“nomhij” : "hijo1"}
> {“nompap” : “papa1”,“nomhij” : "hijo2"}
> {“nompap” : “papa1”,“nomhij” : "hijo3"}
> {“nompap” : “papa2”,“nomhij” : "hijo21"}
> {“nompap” : “papa2”,“nomhij” : "hijo22"}
>
>
> Saludos;
> César Céspedes Loayza
> ________________________________
Parece algo que con un doble loop se debería sacar sin problema.
¿no estarás teniendo problemas por el hecho de que hijos es una lista en lugar
de un dict?
Jose
_______________________________________________
Python-es mailing list
Python-es@python.org
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/