Michel
Michel

Reputation: 11749

Parse.Query with updatedAt not working on Parse-Server

In a cloud function hosted on Parse.com, I used to have the following lines of code working:

var recordListQuery;
recordListQuery = new Parse.Query("TheClassName");
recordListQuery.descending("currentRecord,-updatedAt");

When moving the code to Parse-Server I got this error message:

.... [Error]: (
        {
        code = 105;
        message = "Invalid field name: -updatedAt.";
    }
) (Code: 141, Version: 1.14.2)

After taking a close look at the database, I noticed some changes in Parse-Server, updatedAt is now called _updated_at therefore I changed the above last line of code to:

recordListQuery.descending("currentRecord,-_updated_at");

But now I get the error message:

.... [Error]: (
        {
        code = 105;
        message = "Invalid field name: -_updated_at.";
    }
) (Code: 141, Version: 1.14.2)

Obviously I am not doing it all right. What am I missing?

Upvotes: 0

Views: 343

Answers (1)

Michel
Michel

Reputation: 11749

In case it may be useful to someone, after trying many possibilities, here is what I found and it works.

I replaced this line of code:

recordListQuery.descending("currentRecord,-updatedAt");

by these two:

recordListQuery.descending("currentRecord");
recordListQuery.addAscending("updatedAt");

Upvotes: 0

Related Questions