Skip to content

Commit 474a893

Browse files
committed
Pass the Parse Schema into untransform
1 parent fe81604 commit 474a893

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Adapters/Storage/Mongo/MongoStorageAdapter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ export class MongoStorageAdapter {
199199

200200
// Executes a find. Accepts: className, query in Parse format, and { skip, limit, sort }.
201201
// Accepts the schemaController for legacy reasons.
202-
find(className, query, { skip, limit, sort }, schemaController) {
202+
find(className, query, { skip, limit, sort }, schemaController, schema) {
203203
return this.adaptiveCollection(className)
204204
.then(collection => collection.find(query, { skip, limit, sort }))
205-
.then(objects => objects.map(object => transform.mongoObjectToParseObject(schemaController, className, object)));
205+
.then(objects => objects.map(object => transform.mongoObjectToParseObject(schemaController, className, object, schema)));
206206
}
207207

208208
get transform() {

src/Adapters/Storage/Mongo/MongoTransform.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ const nestedMongoObjectToNestedParseObject = mongoObject => {
755755

756756
// Converts from a mongo-format object to a REST-format object.
757757
// Does not strip out anything based on a lack of authentication.
758-
const mongoObjectToParseObject = (schema, className, mongoObject) => {
758+
const mongoObjectToParseObject = (schemaController, className, mongoObject, schema) => {
759759
switch(typeof mongoObject) {
760760
case 'string':
761761
case 'number':
@@ -831,8 +831,8 @@ const mongoObjectToParseObject = (schema, className, mongoObject) => {
831831
if (key.indexOf('_p_') == 0) {
832832
var newKey = key.substring(3);
833833
var expected;
834-
if (schema && schema.getExpectedType) {
835-
expected = schema.getExpectedType(className, newKey);
834+
if (schemaController && schemaController.getExpectedType) {
835+
expected = schemaController.getExpectedType(className, newKey);
836836
}
837837
if (!expected) {
838838
log.info('transform.js',
@@ -861,7 +861,7 @@ const mongoObjectToParseObject = (schema, className, mongoObject) => {
861861
} else if (key[0] == '_' && key != '__type') {
862862
throw ('bad key in untransform: ' + key);
863863
} else {
864-
var expectedType = schema.getExpectedType(className, key);
864+
var expectedType = schemaController.getExpectedType(className, key);
865865
var value = mongoObject[key];
866866
if (expectedType && expectedType.type === 'File' && FileCoder.isValidDatabaseObject(value)) {
867867
restObject[key] = FileCoder.databaseToJSON(value);
@@ -876,7 +876,7 @@ const mongoObjectToParseObject = (schema, className, mongoObject) => {
876876
}
877877
}
878878

879-
return { ...restObject, ...schema.getRelationFields(className) };
879+
return { ...restObject, ...schemaController.getRelationFields(className) };
880880
default:
881881
throw 'unknown js type';
882882
}

src/Controllers/DatabaseController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ DatabaseController.prototype.find = function(className, query, {
701701
delete mongoOptions.limit;
702702
return collection.count(mongoWhere, mongoOptions);
703703
} else {
704-
return this.adapter.find(className, mongoWhere, mongoOptions, schemaController)
704+
return this.adapter.find(className, mongoWhere, mongoOptions, schemaController, schema)
705705
.then(objects => objects.map(object => filterSensitiveData(isMaster, aclGroup, className, object)));
706706
}
707707
});

0 commit comments

Comments
 (0)