Unique indexes (#1971)
* Add unique indexing * Add unique indexing for username/email * WIP * Finish unique indexes * Notes on how to upgrade to 2.3.0 safely * index on unique-indexes: c454180 Revert "Log objects rather than JSON stringified objects (#1922)" * reconfigure username/email tests * Start dealing with test shittyness * Remove tests for files that we are removing * most tests passing * fix failing test * Make specific server config for tests async * Fix more tests * fix more tests * Fix another test * fix more tests * Fix email validation * move some stuff around * Destroy server to ensure all connections are gone * Fix broken cloud code * Save callback to variable * no need to delete non existant cloud * undo * Fix all tests where connections are left open after server closes. * Fix issues caused by missing gridstore adapter * Update guide for 2.3.0 and fix final tests * use strict * don't use features that won't work in node 4 * Fix syntax error * Fix typos * Add duplicate finding command * Update 2.3.0.md
This commit is contained in:
@@ -61,19 +61,12 @@ function DatabaseController(adapter, { skipValidation } = {}) {
|
||||
// it. Instead, use loadSchema to get a schema.
|
||||
this.schemaPromise = null;
|
||||
this.skipValidation = !!skipValidation;
|
||||
this.connect();
|
||||
}
|
||||
|
||||
DatabaseController.prototype.WithoutValidation = function() {
|
||||
return new DatabaseController(this.adapter, {collectionPrefix: this.collectionPrefix, skipValidation: true});
|
||||
}
|
||||
|
||||
// Connects to the database. Returns a promise that resolves when the
|
||||
// connection is successful.
|
||||
DatabaseController.prototype.connect = function() {
|
||||
return this.adapter.connect();
|
||||
};
|
||||
|
||||
DatabaseController.prototype.schemaCollection = function() {
|
||||
return this.adapter.schemaCollection();
|
||||
};
|
||||
@@ -87,8 +80,7 @@ DatabaseController.prototype.validateClassName = function(className) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (!SchemaController.classNameIsValid(className)) {
|
||||
const error = new Parse.Error(Parse.Error.INVALID_CLASS_NAME, 'invalid className: ' + className);
|
||||
return Promise.reject(error);
|
||||
return Promise.reject(new Parse.Error(Parse.Error.INVALID_CLASS_NAME, 'invalid className: ' + className));
|
||||
}
|
||||
return Promise.resolve();
|
||||
};
|
||||
@@ -417,7 +409,6 @@ DatabaseController.prototype.canAddField = function(schema, className, object, a
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
// Deletes everything in the database matching the current collectionPrefix
|
||||
// Won't delete collections in the system namespace
|
||||
// Returns a promise.
|
||||
DatabaseController.prototype.deleteEverything = function() {
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
/** @flow weak */
|
||||
|
||||
import * as DatabaseAdapter from "../DatabaseAdapter";
|
||||
import * as triggers from "../triggers";
|
||||
import * as Parse from "parse/node";
|
||||
import * as request from "request";
|
||||
import { logger } from '../logger';
|
||||
import * as triggers from "../triggers";
|
||||
import * as Parse from "parse/node";
|
||||
import * as request from "request";
|
||||
import { logger } from '../logger';
|
||||
|
||||
const DefaultHooksCollectionName = "_Hooks";
|
||||
|
||||
export class HooksController {
|
||||
_applicationId:string;
|
||||
_collectionPrefix:string;
|
||||
_collection;
|
||||
|
||||
constructor(applicationId:string, collectionPrefix:string = '', webhookKey) {
|
||||
constructor(applicationId:string, databaseController, webhookKey) {
|
||||
this._applicationId = applicationId;
|
||||
this._collectionPrefix = collectionPrefix;
|
||||
this._webhookKey = webhookKey;
|
||||
this.database = DatabaseAdapter.getDatabaseConnection(this._applicationId, this._collectionPrefix).WithoutValidation();
|
||||
this.database = databaseController;
|
||||
}
|
||||
|
||||
load() {
|
||||
|
||||
@@ -43,7 +43,7 @@ export class UserController extends AdaptableController {
|
||||
if (!this.shouldVerifyEmails) {
|
||||
// Trying to verify email when not enabled
|
||||
// TODO: Better error here.
|
||||
return Promise.reject();
|
||||
throw undefined;
|
||||
}
|
||||
let database = this.config.database.WithoutValidation();
|
||||
return database.update('_User', {
|
||||
@@ -51,7 +51,7 @@ export class UserController extends AdaptableController {
|
||||
_email_verify_token: token
|
||||
}, {emailVerified: true}).then(document => {
|
||||
if (!document) {
|
||||
return Promise.reject();
|
||||
throw undefined;
|
||||
}
|
||||
return Promise.resolve(document);
|
||||
});
|
||||
@@ -64,7 +64,7 @@ export class UserController extends AdaptableController {
|
||||
_perishable_token: token
|
||||
}, {limit: 1}).then(results => {
|
||||
if (results.length != 1) {
|
||||
return Promise.reject();
|
||||
throw undefined;
|
||||
}
|
||||
return results[0];
|
||||
});
|
||||
@@ -85,7 +85,7 @@ export class UserController extends AdaptableController {
|
||||
var query = new RestQuery(this.config, Auth.master(this.config), '_User', where);
|
||||
return query.execute().then(function(result){
|
||||
if (result.results.length != 1) {
|
||||
return Promise.reject();
|
||||
throw undefined;
|
||||
}
|
||||
return result.results[0];
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user