Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an improved syntax for projections #579

Open
patrick-steele-idem opened this issue Feb 6, 2013 · 0 comments
Open

Provide an improved syntax for projections #579

patrick-steele-idem opened this issue Feb 6, 2013 · 0 comments

Comments

@patrick-steele-idem
Copy link

Examples of improvements:

QUERY:

select {
    count as totalCount,
    searchResult.items as items[{
        itemId as id, 
        label as label,
        primaryCategory.categoryName as categoryName,
        shippingInfo {
            shippingType,
            shipToLocation
        }
    }]
}
from finding

OUTPUT:

{
    totalCount: 100,
    items: [
        {
            id: 12345,
            label: 'Test',
            categoryName: 'Athletic',
            shippingInfo: {
                shippingType: "Calculated",
                shipToLocation: "US"
            }
        },
        ...
    ]
}

Also, an "anonymous" top-level array could be returned by dropping the label for "searchResult.items" as shown in the following query:

QUERY:

select searchResult.items as [{
    itemId as id, 
    label,
    primaryCategory.categoryName as categoryName,
    shippingInfo {
        shippingType,
        shipToLocation
    }
}]
from finding

OUTPUT:

[
    {
        id: 12345,
        label: 'Test',
        categoryName: 'Athletic',
        shippingInfo: {
            shippingType: "Calculated",
            shipToLocation: "US"
        }
    },
    ...
]

Also, I think a limit on any arrays should be supported. For example:

QUERY:

select {
    count as totalCount,
    searchResult.items as items[limit=5, {
        itemId as id, 
        label as label,
        primaryCategory.categoryName as categoryName,
        shippingInfo {
            shippingType,
            shipToLocation
        }
    }]
}
from finding

Also, user functions for controlling property values would be helpful as well. For example:

QUERY:

var formatCurrency = require('utils/formatting').formatCurrency; 

select {
    totalCount,
    searchResult.items as items[{
       formatCurrency(buyItNowPrice.$t, buyItNowPrice.currencyId) as buyItNowPrice
    }]
}
from finding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant