Skip to content

Setting default values#311

Merged
brianc merged 1 commit into
brianc:masterfrom
kanthoney:default_values
Dec 20, 2016
Merged

Setting default values#311
brianc merged 1 commit into
brianc:masterfrom
kanthoney:default_values

Conversation

@kanthoney
Copy link
Copy Markdown
Contributor

I might have overlooked something blindingly obvious, but I couldn't find any way of setting the default value of a column when creating a table. This pull request adds a defaultValue parameter which does just that.

Synopsis:

var table = sql.define({
  name: 'test',
  columns:
  [
    {
      name: 'id',
      dataType: 'int',
      primaryKey: true
    },
    {
      name: 'favourite_vegetable',
      dataType: 'text',
      defaultValue: 'cauliflower'
    }
  ]
});

Produces the table creation query

CREATE TABLE "test" ("id" int PRIMARY KEY, "favourite_vegetable" text DEFAULT 'cauliflower')

@brianc brianc merged commit 2808409 into brianc:master Dec 20, 2016
@brianc
Copy link
Copy Markdown
Owner

brianc commented Dec 20, 2016

Thanks a lot for your work on this! Sorry it took me a while to get to it - life got in the way & I got really busy tending to some things. I'll merge this now & push a new minor version to npm here in just a few minutes. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants