a guest Sep 15th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- # Learning A New Codebase
- They provide a cleaner way to write functions using promises, with easier ways of dealing with error handling, conditionals, etc., especially for complex asynchronous code.
- **2. With respect to Knex, how does the transaction method relate to BEGIN and COMMIT syntax in PostgreSQL?**
- The transaction method allows queries to be grouped in a single database connection so that if anything fails within the transaction, it will roll back the previous lines, keeping the database consistent and safe from errors. This is exactly how BEGIN and COMMIT work in PostgreSQL--everything between those two commands tries to run and will roll back upon hitting any failures.
- **3. What is a "sequence table" in PostgreSQL?**
- A sequence table is a table of integers used to generate ids for other tables. The values in these tables can be controlled in various ways--being reset, given inital values, and increment values, etc.
- **4. What does RESTART IDENTITY CASCADE do?**
- This resets the sequence table for the associated table, so that the ids start over from the beginning when the table is truncated and re-created.
- **5. What does SELECT setval('blogful_users_id_seq', 1) do?**
- This sets the integer in sequence for 'blogful_users_id_seq' to 1, meaning blogful_users will return to generating ids at 1.
RAW Paste Data