Parse-server: Order by nested objects

Created on 20 Jun 2016  路  8Comments  路  Source: parse-community/parse-server

I am skipping on the issue template because this is not a bug.

I have an object with a Pointer to User (named creator). I want to be able to order by the full_name field on User

Currently, if I do order('creator.full_name') i get the following error:

{"code":105,"error":"creator.full_name is not a valid order key"}

Would it be possible to implement this in parse-server? Would a PR be accepted for the same?

enhancement stale up for grabs

Most helpful comment

+1 for this, I cannot count the times I stumbled upon this caveat.

It would be very helpful if the dot notation on a subquery could be used to filter / order the superquery. Just by counting the number of references to this limitation when doing a Google search I am sure that this is a much desired feature.

All 8 comments

+1 for this, I cannot count the times I stumbled upon this caveat.

It would be very helpful if the dot notation on a subquery could be used to filter / order the superquery. Just by counting the number of references to this limitation when doing a Google search I am sure that this is a much desired feature.

Any updates for this?

Looking for the feature too

PRs are welcome @iwantooxxoox @JHHMobile @mtrezza @codebreach

Any workaround on this?

@rooswelt
My workaround is to add a middleware before ParseServer middleware, override res.send to get response body and do any kind of sorting that you want there.

example:

app.use(YOUR_ENDPOINT, (req, res, next) => {
  res.sendResponse = res.send;
  res.send = (body) => {
    const bodyObj = JSON.parse(body);
    bodyObj.results.sort((a, b) => a.links[cnty].order - b.links[cnty].order);
    return res.sendResponse(JSON.stringify(bodyObj));
  };
  next();
});
app.use(MOUNT_PATH, parseServer);

@iwantooxxoox
Thanks but that approach force me to load the entire collection then sort...unfortunately that's not an option for me 'cause I've thousands of entities to load...

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shardul08 picture shardul08  路  3Comments

jiawenzhang picture jiawenzhang  路  4Comments

darkprgrmmr picture darkprgrmmr  路  4Comments

carjo422 picture carjo422  路  3Comments

ShawnBaek picture ShawnBaek  路  4Comments