Update dependencies & fix misc formatting errors

This commit is contained in:
2022-09-30 12:02:39 -05:00
parent 52762bd4a1
commit 0484a586bd
23 changed files with 932 additions and 2797 deletions

View File

@@ -1,4 +1,4 @@
import {Container, Inject, Injectable} from '../../di'
import {Inject, Injectable} from '../../di'
import {Migrator} from './Migrator'
import {DatabaseService} from '../DatabaseService'
import {FieldType} from '../types'
@@ -14,9 +14,6 @@ export class DatabaseMigrator extends Migrator {
@Inject()
protected readonly db!: DatabaseService
@Inject('injector')
protected readonly injector!: Container
/** True if we've initialized the migrator. */
protected initialized = false

View File

@@ -1,11 +1,10 @@
import {ModelKey, QueryRow, QuerySource} from '../types'
import {Container, Inject, Instantiable, isInstantiable} from '../../di'
import {Container, Instantiable, isInstantiable} from '../../di'
import {DatabaseService} from '../DatabaseService'
import {ModelBuilder} from './ModelBuilder'
import {getFieldsMeta, ModelField} from './Field'
import {deepCopy, Collection, uuid4, isKeyof, Pipeline, hasOwnProperty} from '../../util'
import {EscapeValueObject, QuerySafeValue} from '../dialect/SQLDialect'
import {Logging} from '../../service/Logging'
import {Connection} from '../connection/Connection'
import {ModelRetrievedEvent} from './events/ModelRetrievedEvent'
import {ModelSavingEvent} from './events/ModelSavingEvent'
@@ -26,9 +25,6 @@ import {ModelEvent} from './events/ModelEvent'
* Base for classes that are mapped to tables in a database.
*/
export abstract class Model<T extends Model<T>> extends LocalBus<ModelEvent<T>> {
@Inject()
protected readonly logging!: Logging
/**
* The name of the connection this model should run through.
* @type string

View File

@@ -8,18 +8,18 @@ import {ModelBuilder} from '../model/ModelBuilder'
* A model instance which stores records from the ORMCache driver.
*/
export class CacheModel extends Model<CacheModel> {
protected static table = 'caches'; // FIXME allow configuring
protected static table = 'caches' // FIXME allow configuring
protected static key = 'cache_key';
protected static key = 'cache_key'
@Field(FieldType.varchar, 'cache_key')
public cacheKey!: string;
public cacheKey!: string
@Field(FieldType.text, 'cache_value')
public cacheValue!: string;
public cacheValue!: string
@Field(FieldType.timestamp, 'cache_expires')
public cacheExpires?: Date;
public cacheExpires?: Date
public static withCacheKey(key: string): ModelBuilder<CacheModel> {
return this.query<CacheModel>()

View File

@@ -35,7 +35,7 @@ export class ORMSession extends Session {
this.data = this.session.json
} else {
this.session = <SessionModel> Container.getContainer().make(SessionModel)
this.session.uuid = this.key
this.session.sessionUuid = this.key
this.data = {} as SessionData
}
}
@@ -48,7 +48,7 @@ export class ORMSession extends Session {
throw new SessionNotLoadedError()
}
this.session.uuid = this.key
this.session.sessionUuid = this.key
this.session.json = JSON.stringify(this.data)
await this.session.save()
}

View File

@@ -13,8 +13,8 @@ export class SessionModel extends Model<SessionModel> {
protected static populateKeyOnInsert = true
@Field(FieldType.varchar, 'session_uuid')
public uuid!: string;
public sessionUuid!: string
@Field(FieldType.json, 'session_data')
public json!: any;
public json!: any
}