Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nation.js - Making Relational Cool Again?

Nation.js - Making Relational Cool Again?

Tim Griesser

November 07, 2014
Tweet

More Decks by Tim Griesser

Other Decks in Technology

Transcript

  1. Node.js® is a platform built on Chrome's JavaScript runtime for

    easily building fast, scalable network applications. Node.js uses an event- driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
  2. Existing SQL Libs? • Database specific • Mix of ORM

    layer and query layer • No transaction api!! • "Jack of All Trades" • DIY: gets you most of the way there, but…
  3. Other Builder features • Aggregate queries (min, max, sum) •

    Column, subquery aliasing ".as()" • Normalizes missing data in inserts • Tries hard to not let you screw up
  4. Transactions • Snapshot state of the world • Ability to

    ROLLBACK • Prevent others from altering data as you’re working with it (Locks) • A little trickier to pull off in Node
  5. Schema Building • Code to help create and edit the

    database structure • Maintains consistency between datatypes in different query dialects • Used in combination with migrations to keep database properly structured
  6. Object Relational Mapper • Rows -> Objects • Models common

    patterns of relational DB’s • One-to-One • One-to-Many • Many-to-Many
  7. • Takes care of standard SQL queries for you, especially

    for common CRUD operations • model.fetch() • model.fetchAll() • model.save() • model.destroy() Object Relational Mapper
  8. Eager Loading • Avoids the N+1 Query Problem • Find

    an account with associated posts, the comments on those posts, and the accounts that made the comments.
  9. Eager Loading • Avoids the N+1 Query Problem • Find

    an account with "approved" associated posts, the comments on those posts, and the accounts that made the comments.
  10. "Tapping into" the query chain Allows for adding additional query

    parameters dynamically to the model's query
  11. Next Steps: • Better debuggability, error types • Built-in support

    for Postgres- specific features • Continue to refine Bookshelf’s API • 1.0 by year end, or shortly after