0.0.2 • Published 11 months ago

@spikedpunch/stacks-postgres v0.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

stacks-postgres

PostgresSQL plugin for stacks. The underlying implementation uses the Kysely Postgres query builder. This was chosen to provide as much forward functionality as possible.

Model Definitions

let model = stack.create.model('model', {
   name: '' 
})

model.symbols.push({
   name: 'postgres:
})

Model Symbols

NameRequiredTypeDescription
postgres:tablenameoptionalstringThe name of the Postgres Table. Defaultrs to the Model's name.
postgres:customoptionalfunction(builder: CreateTableBuilder<any, any>): Promise<CreateTableBuilder<any, any>>Allows you to fully customize the table creation process. This is a lambda function that provides you with the CreateTableBuilder Object in the underlying library.

Member Symbols

NameRequiredTypeDescription
postgres:datatypeoptionalstringThe Postgres Data Type, as specified here. If not provided the plugin will assign a default based on its type. See the Default Type Mapping table below.
postgres:columnnameoptionalstringThe name of the column for this Member
postgres:customcolumnoptionalfunction(builder: CreateTableBuilder<any, any>): Promise<CreateTableBuilder<any, any>>A custom column definition builder. This exposes the underlying builder to configure the column any way you need.

Examples

Default Type Mapping

JS TypePostgres TypeNotes
stringtext
numberinteger
booleanboolean
array[]Also supports List of Lists, ie int[][]
Object Reftable or composite typeWill use the Type's Table nme or Composite name

Store Context

TODO: Fill out

name: 'stacks:postgres',
version: this.version || 'version-not-set',
store: {
   config: this.config,
   db: this.context.db,
   tables: Array.from(this.context.tableMap.values())
}

Underlying Details

  • Search indexes are created on each table for the id column using btree.
0.0.2

11 months ago