feat: Add option schemaCacheTtl for schema cache pulling as alternative to enableSchemaHooks (#8436)
This commit is contained in:
@@ -139,11 +139,12 @@ export class MongoStorageAdapter implements StorageAdapter {
|
||||
_maxTimeMS: ?number;
|
||||
canSortOnJoinTables: boolean;
|
||||
enableSchemaHooks: boolean;
|
||||
schemaCacheTtl: ?number;
|
||||
|
||||
constructor({ uri = defaults.DefaultMongoURI, collectionPrefix = '', mongoOptions = {} }: any) {
|
||||
this._uri = uri;
|
||||
this._collectionPrefix = collectionPrefix;
|
||||
this._mongoOptions = mongoOptions;
|
||||
this._mongoOptions = { ...mongoOptions };
|
||||
this._mongoOptions.useNewUrlParser = true;
|
||||
this._mongoOptions.useUnifiedTopology = true;
|
||||
this._onchange = () => {};
|
||||
@@ -152,8 +153,11 @@ export class MongoStorageAdapter implements StorageAdapter {
|
||||
this._maxTimeMS = mongoOptions.maxTimeMS;
|
||||
this.canSortOnJoinTables = true;
|
||||
this.enableSchemaHooks = !!mongoOptions.enableSchemaHooks;
|
||||
delete mongoOptions.enableSchemaHooks;
|
||||
delete mongoOptions.maxTimeMS;
|
||||
this.schemaCacheTtl = mongoOptions.schemaCacheTtl;
|
||||
for (const key of ['enableSchemaHooks', 'schemaCacheTtl', 'maxTimeMS']) {
|
||||
delete mongoOptions[key];
|
||||
delete this._mongoOptions[key];
|
||||
}
|
||||
}
|
||||
|
||||
watch(callback: () => void): void {
|
||||
|
||||
@@ -850,13 +850,18 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
_pgp: any;
|
||||
_stream: any;
|
||||
_uuid: any;
|
||||
schemaCacheTtl: ?number;
|
||||
|
||||
constructor({ uri, collectionPrefix = '', databaseOptions = {} }: any) {
|
||||
const options = { ...databaseOptions };
|
||||
this._collectionPrefix = collectionPrefix;
|
||||
this.enableSchemaHooks = !!databaseOptions.enableSchemaHooks;
|
||||
delete databaseOptions.enableSchemaHooks;
|
||||
this.schemaCacheTtl = databaseOptions.schemaCacheTtl;
|
||||
for (const key of ['enableSchemaHooks', 'schemaCacheTtl']) {
|
||||
delete options[key];
|
||||
}
|
||||
|
||||
const { client, pgp } = createClient(uri, databaseOptions);
|
||||
const { client, pgp } = createClient(uri, options);
|
||||
this._client = client;
|
||||
this._onchange = () => {};
|
||||
this._pgp = pgp;
|
||||
|
||||
@@ -30,6 +30,8 @@ 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>;
|
||||
|
||||
Reference in New Issue
Block a user