Skip to content

GET on collection with 'sort' parameter fails #1786

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

Closed
3 tasks done
araskin opened this issue May 13, 2016 · 4 comments
Closed
3 tasks done

GET on collection with 'sort' parameter fails #1786

araskin opened this issue May 13, 2016 · 4 comments

Comments

@araskin
Copy link

araskin commented May 13, 2016

Check out #1271 for an ideal bug report. The closer your issue report is to that one, the more likely we are to be able to help, and the more likely we will be to fix the issue quickly!

Many members of the community use Stack Overflow and Server Fault to ask questions. Read through the existing questions or ask your own!

For database migration help, please file a bug report at https://parse.com/help#report

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!

Environment Setup

  • Server: 2.2.9 , Max OS X 10.11.14, Macbook Air, local?
  • Database: ??, AWS, hardware ??, remote?

Steps to reproduce

When the following code is called

                $.ajax({

                    url: "http://localhost:1337/parse/classes/SocialPosting/",
                    dataType: "son",
                    type:"GET",
                    headers: appModel.parse._headers,

                    data:{where: kendo.stringify(
                            {
                                'vendor':appModel.getParsePointer(appModel.parse._vendor, "Vendor"),
                                'autoGenerated':options.data.autoGenerated
                            }
                        ),sort:"_createdAt"},
                    success: function(jsonResponse) {
                        options.success(jsonResponse.results);
                    },

                    error: function(jqXHR,textStatus,errorThrown) {
                        options.error(options.data);
                    }
                });

            },

The response is

{"code":102,"error":"Invalid paramater for query: sort"}

Of course if we remove the sort then everything works fine.

@drew-gross
Copy link
Contributor

_createdAt is not a valid key. Try _created_at or createdAt.

@araskin
Copy link
Author

araskin commented May 13, 2016

Tried both. No change in behavior. @drew-gross

@drew-gross drew-gross reopened this May 13, 2016
@drew-gross
Copy link
Contributor

I checked with api.parse.com, and api.parse.com won't crash if you pass a "sort" parameter, but it also won't actually sort the data. The parameter you need to use is "order".

@araskin
Copy link
Author

araskin commented May 13, 2016

Thanks Drew. That did the trick. I guess it was a bug that we brought over from Parse.com. Once I changed it to order I then get the exception that _createdAt is not a valid key. Once I changed it to createdAt everything works.

Thank you. Please close.

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

2 participants