Re: Wide to long transformation in aggregation

From: Boyd Skelton <boydskelton@xxxxxxxxx>
To: mongodb-user <mongodb-user@xxxxxxxxxxxxxxxx>
Date: Wed, 4 May 2016 08:16:08 -0700 (PDT)
Why ads?
Kevin,

My apologies, I was trying to simplify the data:
[
{
  "order_no" : "A",
  "ship_dt": ISODate("2009-05-15T00:00:00Z"),
  "order_dt": ISODate("2008-01-28T00:00:00Z"),
  "start_dt": ISODate("2008-04-02T00:00:00Z"),
  "stop_dt": ISODate("2008-04-18T00:00:00Z")
},
{
  "order_no" : "B",
  "ship_dt": ISODate("2009-05-15T00:00:00Z"),
  "order_dt": ISODate("2008-02-28T00:00:00Z"),
  "start_dt": ISODate("2008-04-15T00:00:00Z"),
  "stop_dt": ISODate("2008-05-01T00:00:00Z")
}
]



On Friday, April 29, 2016 at 12:30:52 AM UTC-5, Kevin Adistambha wrote:

Hi Boyd

asset, start_date, end_date, ship_date

“A”, 2015-01-01, 2015-02-01, 2015-03-01

“B”, 2015-02-01, 2015-02-15, 2015-03-01

Could you provide an actual document that you’re trying to aggregate? The 
example you gave looks like an SQL table and does not accurately show the 
datatype associated with it.

For example, the date aggregation operator 
<https://docs.mongodb.org/manual/reference/operator/aggregation-date/
does not work with string types. It requires an ISODate 
<https://docs.mongodb.org/manual/core/shell-types/#date> type to be able 
to function.

_id : {
year: 2015,
month: 1
},
start:1,
end: 0,
ship: 0
},

Could you elaborate on the meanings of the field names and values, e.g. 
what does “start”, “end”, and “ship” signifies? How are they connected to 
the example you give (which only has “A” and “B”)

Best regards,
Kevin



-- 
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
--- 
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/2b2882bd-a35f-44a8-a79d-2a34396bb417%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Why ads?