Skip to content

Commit af06061

Browse files
committed
Remove transformKey(...)
1 parent 4bfe2c5 commit af06061

File tree

4 files changed

+8
-17
lines changed

4 files changed

+8
-17
lines changed

spec/MongoTransform.spec.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,10 @@ describe('untransformObject', () => {
191191
});
192192
});
193193

194-
describe('transformKey', () => {
195-
it('throws out _password', (done) => {
196-
try {
197-
transform.transformKey(dummySchema, '_User', '_password');
198-
fail('should have thrown');
199-
} catch (e) {
200-
done();
201-
}
194+
describe('transformKeyValue', () => {
195+
it('throws out _password', done => {
196+
expect(() => transform.transformKeyValue(dummySchema, '_User', '_password', null, {validate: true})).toThrow();
197+
done();
202198
});
203199
});
204200

src/Adapters/Storage/Mongo/MongoTransform.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,6 @@ function untransformACL(mongoObject) {
454454
return output;
455455
}
456456

457-
// Transforms a key used in the REST API format to its mongo format.
458-
function transformKey(schema, className, key) {
459-
return transformKeyValue(schema, className, key, null, {validate: true}).key;
460-
}
461-
462457
// A sentinel value that helper transformations return when they
463458
// cannot perform a transformation
464459
function CannotTransform() {}
@@ -1038,7 +1033,7 @@ var FileCoder = {
10381033
};
10391034

10401035
module.exports = {
1041-
transformKey,
1036+
transformKeyValue,
10421037
parseObjectToMongoObjectForCreate,
10431038
transformUpdate,
10441039
transformWhere,

src/Controllers/DatabaseController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ DatabaseController.prototype.find = function(className, query, {
619619
if (sort) {
620620
mongoOptions.sort = {};
621621
for (let key in sort) {
622-
let mongoKey = this.transform.transformKey(schemaController, className, key);
622+
let mongoKey = this.transform.transformKeyValue(schemaController, className, key, null, {validate: true}).key;
623623
mongoOptions.sort[mongoKey] = sort[key];
624624
}
625625
}

src/Controllers/SchemaController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class SchemaController {
253253
this.data[schema.className] = schema.fields;
254254
this.perms[schema.className] = schema.classLevelPermissions;
255255
});
256-
256+
257257
// Inject the in-memory classes
258258
volatileClasses.forEach(className => {
259259
this.data[className] = injectDefaultSchema({
@@ -467,7 +467,7 @@ class SchemaController {
467467
validateField(className, fieldName, type, freeze) {
468468
return this.reloadData().then(() => {
469469
// Just to check that the fieldName is valid
470-
this._collection.transform.transformKey(this, className, fieldName);
470+
this._collection.transform.transformKeyValue(this, className, fieldName, null, {validate: true});
471471

472472
if( fieldName.indexOf(".") > 0 ) {
473473
// subdocument key (x.y) => ok if x is of type 'object'

0 commit comments

Comments
 (0)