Open
Description
Issue Description
When running a simple query on a class from cloud code, the result is an array of pointers to class objects instead of an array of actual objects. When the same query is run on the client it works ok.
This only happens on a specific class (Profile
in my case), the same query on any other class returns the expected output.
Steps to reproduce
Call this cloud function function for a certain class (in this case Profile
):
Parse.Cloud.define('department:getMembers', request => {
return new Parse.Query(Profile).find({useMasterKey: true});
});
Expected Results
If I run the same query from the client: new Parse.Query(Profile).find();
, what I get is a list of Parse Objects as expected:
{
"results": [
{
"objectId": "SmAkS6KX9F",
"accreditations": [
{
"code": 5,
"year": 2013
}
],
"awards": [
{
"name": "gdsf",
"awardedBy": "dsgf",
"year": 2004,
"details": "hfgdfdhgdfhg"
}
],
// more properties...
},
{
"objectId": "MhOASa4bBa",
"accreditations": [],
"awards": [],
// more properties...
},
{
"objectId": "yIIEz9UIGp",
"accreditations": [],
"awards": [],
// more properties...
}
]
}
Actual Outcome
... but when run from cloud code I'm getting just pointers instead of actual objects!:
{
"result": [
{
"__type": "Pointer",
"className": "Profile",
"objectId": "SmAkS6KX9F"
},
{
"__type": "Pointer",
"className": "Profile",
"objectId": "MhOASa4bBa"
},
{
"__type": "Pointer",
"className": "Profile",
"objectId": "yIIEz9UIGp"
}
]
}
Environment Setup
-
Server
- parse-server version (Be specific! Don't say 'latest'.) : 3.1.1
- Operating System: Win10
- Hardware: Intel Core i5-6200U; RAM 12GB
- Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Local
-
Database
- MongoDB version: v4.0.1
- Storage engine: WiredTiger
- Hardware: (same as server) Intel Core i5-6200U; RAM 12GB
- Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): Local
Logs/Trace
info: Ran cloud function department:getMembers for user rhLnSgyBQv with:
Input: {"department":{"__type":"Pointer","className":"Department","objectId":"nBcxb3juBx"}}
Result: [{"__type":"Pointer","className":"Profile","objectId":"SmAkS6KX9F"},{"__type":"Pointer","className":"Profile","objectId":"MhOASa4bBa"},{"__type":"Pointer","className":"Profile","objectId":"yIIEz9UIGp"}] functionName=department:getMembers, __type=Pointer, className=Department, objectId=nBcxb3juBx, user=rhLnSgyBQv
verbose: RESPONSE from [POST] /scope/functions/department:getMembers: {
"response": {
"result": [
{
"__type": "Pointer",
"className": "Profile",
"objectId": "SmAkS6KX9F"
},
{
"__type": "Pointer",
"className": "Profile",
"objectId": "MhOASa4bBa"
},
{
"__type": "Pointer",
"className": "Profile",
"objectId": "yIIEz9UIGp"
}
]
}
} result=[__type=Pointer, className=Profile, objectId=SmAkS6KX9F, __type=Pointer, className=Profile, objectId=MhOASa4bBa, __type=Pointer, className=Profile, objectId=yIIEz9UIGp]
Some more code
For what it's worth, this is the code for the class Profile.ts
.
import Parse from '@parse';
import { User } from '@library/user/user';
// some more imports...
export class Profile extends Parse.Object {
constructor(attributes?: IProfile) {
super('Profile', attributes);
this.accreditations = attributes && attributes.accreditations || [];
this.awards = attributes && attributes.awards || [];
this.seniority = attributes && attributes.seniority || [];
this.degrees = attributes && attributes.degrees || [];
}
get user(): User { return this.get('user'); }
set user(val: User) { this.set('user', val); }
// some more setters and functions...
toJSON(): IProfile {
const json = super.toJSON();
json.photoUrl = this.photoUrl;
return json;
}
}
// IMPORTANT: Register as Parse subclass
Parse.Object.registerSubclass('Profile', Profile);