You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.0 KiB
71 lines
2.0 KiB
import {make} from "./di/src/global.ts";
|
|
import Application from "./lib/src/lifecycle/Application.ts";
|
|
import Scaffolding from "./lib/src/unit/Scaffolding.ts";
|
|
import {Logging} from "./lib/src/service/logging/Logging.ts";
|
|
import Database from "./orm/src/service/Database.ts";
|
|
import { Model } from './orm/src/model/Model.ts'
|
|
import {Field} from "./orm/src/model/Field.ts";
|
|
import {QueryRow, Type} from './orm/src/db/types.ts';
|
|
import {Builder} from "./orm/src/builder/Builder.ts";
|
|
import ObjectResultOperator from "./orm/src/builder/type/result/ObjectResultOperator.ts";
|
|
import {BehaviorSubject} from "./lib/src/support/BehaviorSubject.ts";
|
|
|
|
// TODO enum bit fields
|
|
// TODO JSON field support
|
|
|
|
;(async () => {
|
|
const scaf = make(Scaffolding)
|
|
await scaf.up()
|
|
|
|
const logger = make(Logging)
|
|
|
|
const app = make(Application)
|
|
await app.run()
|
|
|
|
const db = make(Database)
|
|
|
|
await db.postgres('garrettmills', {
|
|
user: 'garrettmills',
|
|
password: 'garrettmills',
|
|
database: 'garrettmills',
|
|
hostname: 'localhost',
|
|
port: 5432,
|
|
})
|
|
|
|
class User extends Model<User> {
|
|
protected static connection = 'garrettmills'
|
|
protected static table = 'daton_users'
|
|
protected static key = 'user_id'
|
|
|
|
protected static appends: string[] = ['display_name']
|
|
protected static masks: string[] = ['active']
|
|
|
|
@Field(Type.int)
|
|
public user_id!: number
|
|
|
|
@Field(Type.varchar)
|
|
public username!: string
|
|
|
|
@Field(Type.varchar)
|
|
public first_name!: string
|
|
|
|
@Field(Type.varchar)
|
|
public last_name!: string
|
|
|
|
@Field(Type.boolean)
|
|
public active!: boolean
|
|
|
|
@Field(Type.timestamp)
|
|
public updated_at!: Date
|
|
|
|
@Field(Type.timestamp)
|
|
public created_at!: Date
|
|
|
|
get display_name(): string {
|
|
return `${this.last_name}, ${this.first_name}`
|
|
}
|
|
}
|
|
|
|
const u = await User.find_one({ username: 'garrettmills' })
|
|
})()
|