@spikedpunch/stacks-postgres
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

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

Name Required Type Description
postgres:tablename optional string The name of the Postgres Table. Defaultrs to the Model's name.
postgres:custom optional function(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

Name Required Type Description
postgres:datatype optional string The 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:columnname optional string The name of the column for this Member
postgres:customcolumn optional function(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 Type Postgres Type Notes
string text
number integer
boolean boolean
array [] Also supports List of Lists, ie int[][]
Object Ref table or composite type Will 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.

Readme

Keywords

none

Package Sidebar

Install

npm i @spikedpunch/stacks-postgres

Weekly Downloads

3

Version

0.0.2

License

ISC

Unpacked Size

157 kB

Total Files

38

Last publish

Collaborators

  • spikedpunchvictim