Skip to content

Instantly share code, notes, and snippets.

@HyunwooMoon-developer
Created January 14, 2021 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HyunwooMoon-developer/7aee387ce92669151274efd9c586929f to your computer and use it in GitHub Desktop.
Save HyunwooMoon-developer/7aee387ce92669151274efd9c586929f to your computer and use it in GitHub Desktop.
How are the syntaxes async and await useful when writing JavaScript code?
A) An async function is a function declared with the async keyword.
Async functions are instances of the AsyncFunction constructor, and the await keyword is permitted within them.
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.
With respect to Knex, how does the transaction method relate to BEGIN and COMMIT syntax in PostgreSQL?
A)Used by knex.transaction, the transacting method may be chained to any query and passed the object you wish to join the query as part of the transaction for.
What is a "sequence table" in PostgreSQL?
A)By definition, a sequence is a ordered list of integers. The orders of numbers in the sequence are important.
For example, {1,2,3,4,5} and {5,4,3,2,1} are entirely different sequences.
A sequence in PostgreSQL is a user-defined schema-bound object that generates a sequence of integers based on a specified specification.
To create a sequence in PostgreSQL, you use the CREATE SEQUENCE statement.
What does RESTART IDENTITY CASCADE do?
A) RESTART IDENTITY : Automatically restart sequences owned by columns of the truncated table(s).
CASCADE : Automatically truncate all tables that have foreign-key references to any of the named tables, or to any tables added to the group due to CASCADE.
What does SELECT setval('blogful_users_id_seq', 1) do?
A)setval : Reset the sequence object's counter value.
The two-parameter form sets the sequence's last_value field to the specified value and sets its is_called field to true, meaning that the next nextval will advance the sequence before returning a value.
In the three-parameter form, is_called may be set either true or false.
If it's set to false, the next nextval will return exactly the specified value, and sequence advancement commences with the following nextval.
Hints
If the Postgres user setup for thingful-server gets confusing, you can change the server configurations to use dunder_mifflin user as well as creating the databases using that user.
Take a look inside the knex service objects, there is a library called treeize. Treeize is a good candidate to read the documentation for in https://npmjs.com. You can try doing a console.log before and after each time treeize is used. Can you find where treeize is being used?
Take a look at the migrations files, there's a new PostgreSQL syntax for id fields. They're using a type of SERIAL. This would be a good question for a Google search: "What is PostgreSQL SERIAL PRIMARY KEY?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment