Skip to content

Commit 035146b

Browse files
committed
Renames Unsafe to WithoutValidation
1 parent 8ebeb76 commit 035146b

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

src/Controllers/DatabaseController.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ var Parse = require('parse/node').Parse;
99
var Schema = require('./../Schema');
1010
const deepcopy = require('deepcopy');
1111

12-
function DatabaseController(adapter, { unsafe } = {}) {
12+
function DatabaseController(adapter, { skipValidation } = {}) {
1313
this.adapter = adapter;
1414

1515
// We don't want a mutable this.schema, because then you could have
1616
// one request that uses different schemas for different parts of
1717
// it. Instead, use loadSchema to get a schema.
1818
this.schemaPromise = null;
19-
this.unsafe = !!unsafe;
19+
this.skipValidation = !!skipValidation;
2020
this.connect();
2121

2222
Object.defineProperty(this, 'transform', {
@@ -26,8 +26,8 @@ function DatabaseController(adapter, { unsafe } = {}) {
2626
})
2727
}
2828

29-
DatabaseController.prototype.Unsafe = function() {
30-
return new DatabaseController(this.adapter, {collectionPrefix: this.collectionPrefix, unsafe: true});
29+
DatabaseController.prototype.WithoutValidation = function() {
30+
return new DatabaseController(this.adapter, {collectionPrefix: this.collectionPrefix, skipValidation: true});
3131
}
3232

3333
// Connects to the database. Returns a promise that resolves when the
@@ -49,7 +49,7 @@ DatabaseController.prototype.dropCollection = function(className) {
4949
};
5050

5151
DatabaseController.prototype.validateClassName = function(className) {
52-
if (this.unsafe) {
52+
if (this.skipValidation) {
5353
return Promise.resolve();
5454
}
5555
if (!Schema.classNameIsValid(className)) {
@@ -167,11 +167,11 @@ DatabaseController.prototype.update = function(className, query, update, options
167167
.then(() => this.handleRelationUpdates(className, query.objectId, update))
168168
.then(() => this.adapter.adaptiveCollection(className))
169169
.then(collection => {
170-
var mongoWhere = this.transform.transformWhere(schema, className, query, {validate: !this.unsafe});
170+
var mongoWhere = this.transform.transformWhere(schema, className, query, {validate: !this.skipValidation});
171171
if (options.acl) {
172172
mongoWhere = this.transform.addWriteACL(mongoWhere, options.acl);
173173
}
174-
mongoUpdate = this.transform.transformUpdate(schema, className, update, {validate: !this.unsafe});
174+
mongoUpdate = this.transform.transformUpdate(schema, className, update, {validate: !this.skipValidation});
175175
if (options.many) {
176176
return collection.updateMany(mongoWhere, mongoUpdate);
177177
}else if (options.upsert) {
@@ -185,7 +185,7 @@ DatabaseController.prototype.update = function(className, query, update, options
185185
return Promise.reject(new Parse.Error(Parse.Error.OBJECT_NOT_FOUND,
186186
'Object not found.'));
187187
}
188-
if (this.unsafe) {
188+
if (this.skipValidation) {
189189
return Promise.resolve(result);
190190
}
191191
return sanitizeDatabaseResult(originalUpdate, result);
@@ -307,7 +307,7 @@ DatabaseController.prototype.destroy = function(className, query, options = {})
307307
})
308308
.then(() => this.adapter.adaptiveCollection(className))
309309
.then(collection => {
310-
let mongoWhere = this.transform.transformWhere(schema, className, query, {validate: !this.unsafe});
310+
let mongoWhere = this.transform.transformWhere(schema, className, query, {validate: !this.skipValidation});
311311
if (options.acl) {
312312
mongoWhere = this.transform.addWriteACL(mongoWhere, options.acl);
313313
}

src/Controllers/HooksController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class HooksController {
1515
constructor(applicationId:string, collectionPrefix:string = '') {
1616
this._applicationId = applicationId;
1717
this._collectionPrefix = collectionPrefix;
18-
this.database = DatabaseAdapter.getDatabaseConnection(this._applicationId, this._collectionPrefix).Unsafe();
18+
this.database = DatabaseAdapter.getDatabaseConnection(this._applicationId, this._collectionPrefix).WithoutValidation();
1919
}
2020

2121
load() {

src/Controllers/UserController.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class UserController extends AdaptableController {
4545
// TODO: Better error here.
4646
return Promise.reject();
4747
}
48-
let database = this.config.database.Unsafe();
48+
let database = this.config.database.WithoutValidation();
4949
return database.update('_User', {
5050
username: username,
5151
_email_verify_token: token
@@ -58,7 +58,7 @@ export class UserController extends AdaptableController {
5858
}
5959

6060
checkResetTokenValidity(username, token) {
61-
let database = this.config.database.Unsafe();
61+
let database = this.config.database.WithoutValidation();
6262
return database.find('_User', {
6363
username: username,
6464
_perishable_token: token
@@ -115,7 +115,7 @@ export class UserController extends AdaptableController {
115115

116116
setPasswordResetToken(email) {
117117
let token = randomString(25);
118-
let database = this.config.database.Unsafe();
118+
let database = this.config.database.WithoutValidation();
119119
return database.update('_User', {email: email}, {_perishable_token: token});
120120
}
121121

@@ -153,7 +153,7 @@ export class UserController extends AdaptableController {
153153
return updateUserPassword(user.objectId, password, this.config);
154154
}).then(() => {
155155
// clear reset password token
156-
return this.config.database.Unsafe().update('_User', { username }, {
156+
return this.config.database.WithoutValidation().update('_User', { username }, {
157157
_perishable_token: {__op: 'Delete'}
158158
});
159159
});

src/Routers/GlobalConfigRouter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as middleware from "../middlewares";
55

66
export class GlobalConfigRouter extends PromiseRouter {
77
getGlobalConfig(req) {
8-
let database = req.config.database.Unsafe();
8+
let database = req.config.database.WithoutValidation();
99
return database.find('_GlobalConfig', { '_id': 1 }, { limit: 1 }).then((results) => {
1010
if (results.length != 1) {
1111
// If there is no config in the database - return empty config.
@@ -23,7 +23,7 @@ export class GlobalConfigRouter extends PromiseRouter {
2323
acc[`params.${key}`] = params[key];
2424
return acc;
2525
}, {});
26-
let database = req.config.database.Unsafe();
26+
let database = req.config.database.WithoutValidation();
2727
return database.update('_GlobalConfig', {_id: 1}, update, {upsert: true}).then(() => {
2828
return Promise.resolve({ response: { result: true } });
2929
});

src/pushStatusHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function pushStatusHandler(config) {
1919
let initialPromise;
2020
let pushStatus;
2121
let objectId = newObjectId();
22-
let database = config.database.Unsafe();
22+
let database = config.database.WithoutValidation();
2323

2424
let setInitial = function(body = {}, where, options = {source: 'rest'}) {
2525
let now = new Date();

0 commit comments

Comments
 (0)