Unwind document

42 views
Skip to first unread message

Jackson

unread,
Sep 24, 2012, 11:42:13 AM9/24/12
to mongod...@googlegroups.com
Hello all!!!
How can I create project for one document:

{
_id:1,
field1: 5,
field2: 10,
field3: 25
}

to have several documents:
{
_id:2,
field1: 5
},
{
_id:3,
field2: 10
},
{
_id:4,
field3: 25
}

or to have one document with array:
{
_id:1,
fields: [{name:"field1", count:5},{ name:"field2", count:10 },{ name:"field3", count:25 }]
}

?

Jackson

unread,
Sep 24, 2012, 11:45:00 AM9/24/12
to mongod...@googlegroups.com
PS: Using Aggregation Framework

Jason Rassi

unread,
Sep 24, 2012, 2:53:31 PM9/24/12
to mongodb-user
This is not possible with the aggregation framework. You can only
unwind arrays, and creating arrays with the aggregation framework is
not currently supported.

On Sep 24, 11:45 am, Jackson <eugene.se...@gmail.com> wrote:
> PS: Using Aggregation Framework

Jackson

unread,
Sep 25, 2012, 5:13:04 AM9/25/12
to mongod...@googlegroups.com
It's too bad... Are there any plans to implement such functionality in future?

Jason Rassi

unread,
Sep 26, 2012, 11:34:01 AM9/26/12
to mongodb-user
I don't believe so.

Jackson

unread,
Sep 27, 2012, 9:26:11 AM9/27/12
to mongod...@googlegroups.com
Ok, thank you

среда, 26 сентября 2012 г., 18:34:13 UTC+3 пользователь Jason Rassi написал:

craiggwilson

unread,
Sep 27, 2012, 10:31:00 AM9/27/12
to mongod...@googlegroups.com
You can file a SERVER feature request at jira.mongodb.org.  This feature would be similiar to PIVOT in Sql Server I think.
Reply all
Reply to author
Forward
0 new messages