Files
kami-parse-server/src/Adapters/Storage/StorageAdapter.js

137 lines
3.6 KiB
JavaScript
Raw Normal View History

// @flow
export type SchemaType = any;
export type StorageClass = any;
export type QueryType = any;
export type QueryOptions = {
skip?: number,
limit?: number,
acl?: string[],
sort?: { [string]: number },
count?: boolean | number,
keys?: string[],
op?: string,
distinct?: boolean,
pipeline?: any,
readPreference?: ?string,
hint?: ?mixed,
explain?: Boolean,
Case insensitive signup (#5634) * Always delete data after each, even for mongo. * Add failing simple case test * run all tests * 1. when validating username be case insensitive 2. add _auth_data_anonymous to specialQueryKeys...whatever that is! * More case sensitivity 1. also make email validation case insensitive 2. update comments to reflect what this change does * wordsmithery and grammar * first pass at a preformant case insensitive query. mongo only so far. * change name of parameter from insensitive to caseInsensitive * Postgres support * properly handle auth data null * wip * use 'caseInsensitive' instead of 'insensitive' in all places. * update commenet to reclect current plan * skip the mystery test for now * create case insensitive indecies for mongo to support case insensitive checks for email and username * remove unneeded specialKey * pull collation out to a function. * not sure what i planned to do with this test. removing. * remove typo * remove another unused flag * maintain order * maintain order of params * boil the ocean on param sequence i like having explain last cause it seems like something you would change/remove after getting what you want from the explain? * add test to verify creation and use of caseInsensitive index * add no op func to prostgress * get collation object from mongocollection make flow lint happy by declaring things Object. * fix typo * add changelog * kick travis * properly reference static method * add a test to confirm that anonymous users with unique username that do collide when compared insensitively can still be created. * minot doc nits * add a few tests to make sure our spy is working as expected wordsmith the changelog Co-authored-by: Diamond Lewis <findlewis@gmail.com>
2020-02-14 09:44:51 -08:00
caseInsensitive?: boolean,
action?: string,
addsField?: boolean,
comment?: string,
};
export type UpdateQueryOptions = {
many?: boolean,
upsert?: boolean,
};
export type FullQueryOptions = QueryOptions & UpdateQueryOptions;
export interface StorageAdapter {
canSortOnJoinTables: boolean;
schemaCacheTtl: ?number;
enableSchemaHooks: boolean;
classExists(className: string): Promise<boolean>;
setClassLevelPermissions(className: string, clps: any): Promise<void>;
createClass(className: string, schema: SchemaType): Promise<void>;
2020-12-13 11:19:04 -06:00
addFieldIfNotExists(className: string, fieldName: string, type: any): Promise<void>;
updateFieldOptions(className: string, fieldName: string, type: any): Promise<void>;
deleteClass(className: string): Promise<void>;
deleteAllClasses(fast: boolean): Promise<void>;
2020-12-13 11:19:04 -06:00
deleteFields(className: string, schema: SchemaType, fieldNames: Array<string>): Promise<void>;
getAllClasses(): Promise<StorageClass[]>;
getClass(className: string): Promise<StorageClass>;
createObject(
className: string,
schema: SchemaType,
object: any,
transactionalSession: ?any
): Promise<any>;
deleteObjectsByQuery(
className: string,
schema: SchemaType,
query: QueryType,
transactionalSession: ?any
): Promise<void>;
updateObjectsByQuery(
className: string,
schema: SchemaType,
query: QueryType,
update: any,
transactionalSession: ?any
): Promise<[any]>;
findOneAndUpdate(
className: string,
schema: SchemaType,
query: QueryType,
update: any,
transactionalSession: ?any
): Promise<any>;
upsertOneObject(
className: string,
schema: SchemaType,
query: QueryType,
update: any,
transactionalSession: ?any
): Promise<any>;
find(
className: string,
schema: SchemaType,
query: QueryType,
options: QueryOptions
): Promise<[any]>;
Case insensitive signup (#5634) * Always delete data after each, even for mongo. * Add failing simple case test * run all tests * 1. when validating username be case insensitive 2. add _auth_data_anonymous to specialQueryKeys...whatever that is! * More case sensitivity 1. also make email validation case insensitive 2. update comments to reflect what this change does * wordsmithery and grammar * first pass at a preformant case insensitive query. mongo only so far. * change name of parameter from insensitive to caseInsensitive * Postgres support * properly handle auth data null * wip * use 'caseInsensitive' instead of 'insensitive' in all places. * update commenet to reclect current plan * skip the mystery test for now * create case insensitive indecies for mongo to support case insensitive checks for email and username * remove unneeded specialKey * pull collation out to a function. * not sure what i planned to do with this test. removing. * remove typo * remove another unused flag * maintain order * maintain order of params * boil the ocean on param sequence i like having explain last cause it seems like something you would change/remove after getting what you want from the explain? * add test to verify creation and use of caseInsensitive index * add no op func to prostgress * get collation object from mongocollection make flow lint happy by declaring things Object. * fix typo * add changelog * kick travis * properly reference static method * add a test to confirm that anonymous users with unique username that do collide when compared insensitively can still be created. * minot doc nits * add a few tests to make sure our spy is working as expected wordsmith the changelog Co-authored-by: Diamond Lewis <findlewis@gmail.com>
2020-02-14 09:44:51 -08:00
ensureIndex(
className: string,
schema: SchemaType,
fieldNames: string[],
indexName?: string,
caseSensitive?: boolean,
options?: Object
Case insensitive signup (#5634) * Always delete data after each, even for mongo. * Add failing simple case test * run all tests * 1. when validating username be case insensitive 2. add _auth_data_anonymous to specialQueryKeys...whatever that is! * More case sensitivity 1. also make email validation case insensitive 2. update comments to reflect what this change does * wordsmithery and grammar * first pass at a preformant case insensitive query. mongo only so far. * change name of parameter from insensitive to caseInsensitive * Postgres support * properly handle auth data null * wip * use 'caseInsensitive' instead of 'insensitive' in all places. * update commenet to reclect current plan * skip the mystery test for now * create case insensitive indecies for mongo to support case insensitive checks for email and username * remove unneeded specialKey * pull collation out to a function. * not sure what i planned to do with this test. removing. * remove typo * remove another unused flag * maintain order * maintain order of params * boil the ocean on param sequence i like having explain last cause it seems like something you would change/remove after getting what you want from the explain? * add test to verify creation and use of caseInsensitive index * add no op func to prostgress * get collation object from mongocollection make flow lint happy by declaring things Object. * fix typo * add changelog * kick travis * properly reference static method * add a test to confirm that anonymous users with unique username that do collide when compared insensitively can still be created. * minot doc nits * add a few tests to make sure our spy is working as expected wordsmith the changelog Co-authored-by: Diamond Lewis <findlewis@gmail.com>
2020-02-14 09:44:51 -08:00
): Promise<any>;
2020-12-13 11:19:04 -06:00
ensureUniqueness(className: string, schema: SchemaType, fieldNames: Array<string>): Promise<void>;
count(
className: string,
schema: SchemaType,
query: QueryType,
readPreference?: string,
estimate?: boolean,
hint?: mixed,
comment?: string
): Promise<number>;
distinct(
className: string,
schema: SchemaType,
query: QueryType,
fieldName: string
): Promise<any>;
aggregate(
className: string,
schema: any,
pipeline: any,
readPreference: ?string,
hint: ?mixed,
explain?: boolean,
comment?: string
): Promise<any>;
performInitialization(options: ?any): Promise<void>;
watch(callback: () => void): void;
// Indexing
createIndexes(className: string, indexes: any, conn: ?any): Promise<void>;
getIndexes(className: string, connection: ?any): Promise<void>;
updateSchemaWithIndexes(): Promise<void>;
setIndexesWithSchemaFormat(
className: string,
submittedIndexes: any,
existingIndexes: any,
fields: any,
conn: ?any
): Promise<void>;
createTransactionalSession(): Promise<any>;
commitTransactionalSession(transactionalSession: any): Promise<void>;
abortTransactionalSession(transactionalSession: any): Promise<void>;
}