Create InjectSession & PersistSession modules; update session model
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user