Create InjectSession & PersistSession modules; update session model

This commit is contained in:
garrettmills
2020-07-27 19:48:44 -05:00
parent 25a37cf1a2
commit a6995c6a85
14 changed files with 149 additions and 14 deletions

View File

@@ -16,6 +16,7 @@ export default class PostgresConnection extends Connection {
public async query(query: string) {
if ( !this._client ) throw new ConnectionNotReadyError(this.name)
logger.verbose(`Executing query: \n${query}`)
const result = await this._client.query(query)
let base_i = 0

View File

@@ -38,6 +38,11 @@ export abstract class Model<T extends Model<T>> extends Builder<T> {
*/
protected static key: string
/**
* If false (default), the primary key will be excluded from INSERTs.
*/
protected static populate_key_on_insert: boolean = false
/**
* Optionally, the timestamp field set on creation.
* @type string
@@ -642,7 +647,11 @@ export abstract class Model<T extends Model<T>> extends Builder<T> {
* @return FieldValueObject
*/
protected _build_insert_field_object(): FieldValueObject {
const fields = this.field_defs().whereNot('model_key', '=', this.key_name())
let fields = this.field_defs()
if ( !(this.constructor as typeof Model).populate_key_on_insert )
fields = fields.whereNot('model_key', '=', this.key_name())
const values = {}
fields.each(field_def => {
// @ts-ignore