tracker issue : CF-4073770

select a category, or use search below
(searches all categories and all time range)
Title:

queryExecute - Add Map function

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/

Reporter/Name(from Bugbase): Abram Adams / Abram Adams (Abram Adams)

Created: 10/14/2015

Components: Language

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Linux

Vote Count: 1

This feature makes a lot more sense if https://bugbase.adobe.com/index.cfm?event=bug&id=4073759 gets emplemented as well...

It would be very useful to be able to pass in a map function to the queryExecute function that would execute for each row in the results and allow you to transform the results.  Like mentioned above, this would make more sense if the queryExecute method had a returntype that would allow you to return an array of structs.

Here's an example of how it would be used (assuming returnType ER is implemented):

users = queryExecute(
   "SELECT userId, name 
    FROM users 
    WHERE userId = :userId , 
   {userid=1},
   {returnType="array"},
   function( row ){
      row[ "policies" ] = someService.getUserPolicies( row.userID );
      row[ "friends" ] = queryExecute(
                                  "SELECT userId, name 
                                   FROM users u
                                  JOIN userFriends uf on uf.friendId = u.userId 
                                  WHERE uf.userId = :userId",
                                 {userId: row.userId }, 
                                 {returnType="array"});
     return row;
   }
);

This would output something like:
[
   {id:1,name:"joe",policies:[{policyId:123},{policyId:145},{policyId:354}],friends: [{id:2,name:"jill"},{id:4,name:"bob"}]},
   {id:2,name:"jill",policies:[{policyId:654},{policyId:655},{policyId:789}],friends: [{id:1,name:"joe"},{id:4,name:"bob"}]}
]

As you can see, this would allow you to build out rich relational data structures fairly simply.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4073770

External Customer Info:
External Company:  
External Customer Name: Abram Adams
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

I think this is the wrong approach to the requirement here, Abram: you're asking queryExecute() to now do two things. All Adobe need to do is to implement iteration methods on queries, eg .map(). This has already been flagged for implementation via https://bugbase.adobe.com/index.cfm?event=bug&id=CF-4022420
Comment by External U.
5582 | October 14, 2015 01:01:00 PM GMT
Adam, I agree. My original idea behind this was to add a convenience to the queryExecute function, but you're right; queryExecute should just execute queries. If we get the map function on query objects (and they behave exactly like array maps), then we're golden. Now Adobe, get on that query.map() feature and make it happen!
Comment by External U.
5583 | October 14, 2015 02:27:57 PM GMT
We will be adding map and reduce member functions on query object as part of #CF-3713323
Comment by Vamseekrishna N.
5584 | October 14, 2015 11:01:21 PM GMT
+1111111111111111111111111
Vote by External U.
5585 | October 15, 2015 09:20:12 AM GMT