It worked. Just to complete the answer, if I want 3 columns (userId, excursion, picnic for example) The query looks something like:
SELECT userId, traceElements[type = 'excursion'].data as excursion, traceElements[type = 'picnic'].data as picnic from User UNWIND excursion, picnic On Wednesday, April 13, 2016 at 12:26:24 AM UTC-7, Luigi Dell'Aquila wrote: > > Hi Pablo, you can try this: > > SELECT userId, activities[type = 'excursion'] as excursionActivities from > from User unwind excursionActivities > > Thanks > > Luigi > > 2016-04-13 1:28 GMT+02:00 pabloa <pabl...@gmail.com <javascript:>>: > >> Hello >> >> I have a class User with 2 fields in a graph database >> >> User >> ==== >> userId --> integer >> activities --> list of objects >> >> "activities" values are list of objects. Those objects are not real >> entities, so I added them in the class. For example: >> >> { >> "userId":23232, >> "activities": [{"day": 27, "type": "excursion", data: "Buenos >> Aires"}, {"day": 28, "type": "picnic", data: "Delta Tigre"}, {"day": 30, >> "type": "nightclub", data: "Oh lalala"}, .... ] >> } >> >> Each user in User class have his/her activities. >> >> I want all the activities in all the users, but only of type "excursion". >> I execute this query: >> >> SELECT userId, value.data FROM ( >> SELECT userId, expand(activities) FROM User >> ) >> WHERE value.type = 'excursion' >> >> But it returns only 1 row of the first user activity without userId >> column. >> >> I would like to obtain something like: >> >> userId, data >> 1, Buenos Aires >> 2, Paris >> 3, Monte Comán >> >> How could I query by all the activities or all the data of activities of >> type "excursion"? >> >> I am using OrientDb 2.1.15 >> >> besides, I am getting a tip saying the subquery is returning more than >> 10000 rows (I have like 90000 rows in User class). >> >> I am open to refactor the model. What I need to is to have activities >> sorted as they are in the list and findable by user or by their selves. >> >> Pablo >> >> >> -- >> >> --- >> You received this message because you are subscribed to the Google Groups >> "OrientDB" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to orient-databa...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.