Improves Controller and Adapter relationship
- Controllers that have adapters are AdaptableControllers - AdaptableController is responsible to instantiate the proper adapter if needed (string, function or BaseAdapter) - BaseAdapter is the base class for adapters, allows skipping when passed directly to the controller
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Parse } from 'parse/node';
|
||||
import PromiseRouter from '../PromiseRouter';
|
||||
import AdaptableController from './AdaptableController';
|
||||
|
||||
const Promise = Parse.Promise;
|
||||
const MILLISECONDS_IN_A_DAY = 24 * 60 * 60 * 1000;
|
||||
@@ -14,11 +15,7 @@ export const LogOrder = {
|
||||
ASCENDING: 'asc'
|
||||
}
|
||||
|
||||
export class LoggerController {
|
||||
|
||||
constructor(loggerAdapter, loggerOptions) {
|
||||
this._loggerAdapter = loggerAdapter;
|
||||
}
|
||||
export class LoggerController extends AdaptableController {
|
||||
|
||||
// check that date input is valid
|
||||
static validDateTime(date) {
|
||||
@@ -59,7 +56,7 @@ export class LoggerController {
|
||||
// order (optional) Direction of results returned, either “asc” or “desc”. Defaults to “desc”.
|
||||
// size (optional) Number of rows returned by search. Defaults to 10
|
||||
getLogs(options= {}) {
|
||||
if (!this._loggerAdapter) {
|
||||
if (!this.adapter) {
|
||||
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED,
|
||||
'Logger adapter is not availabe');
|
||||
}
|
||||
@@ -68,7 +65,7 @@ export class LoggerController {
|
||||
|
||||
options = LoggerController.parseOptions(options);
|
||||
|
||||
this._loggerAdapter.query(options, (result) => {
|
||||
this.adapter.query(options, (result) => {
|
||||
promise.resolve(result);
|
||||
});
|
||||
return promise;
|
||||
|
||||
Reference in New Issue
Block a user