Start routing; rehydratable interface; add verbose logging
This commit is contained in:
@@ -11,6 +11,7 @@ import {logger} from '../../../lib/src/service/logging/global.ts'
|
||||
import {QueryFilter} from './filter.ts'
|
||||
import {BehaviorSubject} from '../../../lib/src/support/BehaviorSubject.ts'
|
||||
import {Scope} from '../builder/Scope.ts'
|
||||
import {JSONState, Rehydratable} from '../../../lib/src/support/Rehydratable.ts'
|
||||
|
||||
// TODO separate read/write connections
|
||||
// TODO manual dirty flags
|
||||
@@ -19,7 +20,7 @@ import {Scope} from '../builder/Scope.ts'
|
||||
* Base class for database models.
|
||||
* @extends Builder
|
||||
*/
|
||||
export abstract class Model<T extends Model<T>> extends Builder<T> {
|
||||
export abstract class Model<T extends Model<T>> extends Builder<T> implements Rehydratable {
|
||||
/**
|
||||
* The name of the connection this model should run through.
|
||||
* @type string
|
||||
@@ -837,4 +838,19 @@ export abstract class Model<T extends Model<T>> extends Builder<T> {
|
||||
public static qualified_key_name() {
|
||||
return `${this.table_name()}.${this.key}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Dehydrate the model. Implements Rehydratable interface.
|
||||
*/
|
||||
public async dehydrate(): Promise<JSONState> {
|
||||
return this.to_object()
|
||||
}
|
||||
|
||||
/**
|
||||
* Rehydrate the model. Implements Rehydratable interface.
|
||||
* @param state
|
||||
*/
|
||||
public async rehydrate(state: JSONState) {
|
||||
this.assume_from_source(state)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user