Skip to content

Aggregations with pointers does not work #5007

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
srameshr opened this issue Aug 27, 2018 · 10 comments
Closed

Aggregations with pointers does not work #5007

srameshr opened this issue Aug 27, 2018 · 10 comments
Labels
type:question Support or code-level question

Comments

@srameshr
Copy link
Contributor

Issue Description

Aggregate query documentation does not mention that the pointer field names should be appended with _p_ while querying.

Steps to reproduce

If you have a pointer field by name createdBy, then:
THIS DOES NOT WORK

{
  project: { 'createdBy': 0 }
} 

** THIS WORKS**

{
  project: { '_p_createdBy': 0 }
} 

Expected Results

Update the docs to reflect this nuance.

Actual Outcome

N/A

Environment Setup

N/A

@srameshr srameshr changed the title Docs do not mention _p_ Docs does not mention _p_ during aggregation Aug 27, 2018
@flovilmart
Copy link
Contributor

Actually it should probably not be the case, I'M not sure why this is like that @dplewis any idea why the keys are not properly transformed?

@flovilmart flovilmart changed the title Docs does not mention _p_ during aggregation Aggregations with pointers does not work Aug 27, 2018
@dplewis
Copy link
Member

dplewis commented Aug 27, 2018

Which version of Parse Server you are running?

There is a test case for this already.

https://github.com/parse-community/parse-server/blob/master/spec/ParseQuery.Aggregate.spec.js#L762

it('project pointer query', (done) => {
    const pointer = new PointerObject();
    const obj = new TestObject({ pointer, name: 'hello' });

    obj.save().then(() => {
      const pipeline = [
        { match: { objectId: obj.id } },
        { project: { pointer: 1, name: 1, createdAt: 1 } }
      ];
      const query = new Parse.Query(TestObject);
      return query.aggregate(pipeline);
    }).then((results) => {
      expect(results.length).toEqual(1);
      expect(results[0].name).toEqual('hello');
      expect(results[0].createdAt).not.toBe(undefined);
      expect(results[0].pointer.objectId).toEqual(pointer.id);
      done();
    });
  });

@flovilmart
Copy link
Contributor

flovilmart commented Aug 27, 2018

I'll be closing this one as we explicitly have a test for it. If you consider reopening an issue, please attach logs as well as server version and also a full code snippet.

@srameshr
Copy link
Contributor Author

@dplewis @flovilmart I was on 2.8.x, after upgrading to 3.0 it works without _p_

@dplewis
Copy link
Member

dplewis commented Aug 28, 2018

@srameshr that’s great! Let us know how the migration goes too

@srameshr
Copy link
Contributor Author

srameshr commented Aug 28, 2018

@dplewis It is breaking, have to replace some of the res.success calls. Thankfully, res.error was in one global utility file.

@flovilmart
Copy link
Contributor

The breaking changes were to be expected.

@srameshr
Copy link
Contributor Author

srameshr commented Aug 28, 2018

One question, out of context to this thread. How do you construct _url for a file field? With aggregation, it just returns the file name something like6a5b69cbe836f5b0c1447ba3e0ea5ece_appname-media.jpeg

@dplewis
Copy link
Member

dplewis commented Aug 28, 2018

@srameshr I honestly have no idea. A PR was just approved on the hash name so I haven't been up-to-date on it

@srameshr
Copy link
Contributor Author

The actual URL is,
http://localhost:1337/parse/files/my_app_id/6a5b69cbe836f5b0c1447ba3e0ea5ece_filename-media.jpeg
I can make some changes to the aggregation query to prepend something like ${SERVER_URL}/parse/files/${MY_APP_ID}/ to the filename, but does this format change if I use Parse File Adapter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

4 participants