Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nathanielmata/c9906280850d20bccdb5ea773ab03217 to your computer and use it in GitHub Desktop.
Save nathanielmata/c9906280850d20bccdb5ea773ab03217 to your computer and use it in GitHub Desktop.
Module14 Checkpoint2 Learning a New Codebase
  1. How are the syntaxes async and await useful when writing JavaScript code?
The async and await keywords enable asynchronous, promise-based behavior to be written in a cleaner style, avoiding the need to explicitly configure promise chains.
  1. With respect to Knex, how does the transaction method relate to BEGIN and COMMIT syntax in PostgreSQL?
Knex transaction() method wraps a sql statement and is equivalent to wrapping a sql statement in BEGIN and COMMIT.
  1. What is a "sequence table" in PostgreSQL?
A sequence table is a sequence number generator that can be applied to other tables. You can set a min and max value like 100 and 1000 and specify where to start incrementing.
https://www.postgresql.org/docs/9.5/sql-createsequence.html
CREATE [ TEMPORARY | TEMP ] SEQUENCE [ IF NOT EXISTS ] name [ INCREMENT [ BY ] increment ]
    [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
    [ START [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]
    [ OWNED BY { table_name.column_name | NONE } ]
  1. What does RESTART IDENTITY CASCADE do?
https://dba.stackexchange.com/questions/193495/postgresql-truncate-a-table-on-cascade-and-reset-all-hierarchic-sequences-with
The TRUNCATE statement has an additional option RESTART IDENTITY which resets the sequences associated with the table columns.
  1. What does SELECT setval('blogful_users_id_seq', 1) do?
https://www.postgresql.org/docs/8.2/functions-sequence.html
Sets the sequence table start value to a given integer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment