Chapter 12. Embedded data and associations

 

This chapter covers

  • Using embedded records and associations to create relationships between models
  • Reducing duplicative code by creating a service
  • Understanding the differences between one-way and two-way associations

In chapter 11, we examined the new requirements of a market-based pivot that significantly enhanced and extended the features of Brushfire. We applied our frontend-first approach to the requirements. Using this approach compelled us to make design decisions in advance of implementing the backend, thereby reducing the likelihood of second-guessing based on inadequate information. Essentially, we wanted to eliminate questions that begin with “I didn’t know that....” Our work in chapter 11 produced a set of documented decision points in the API Reference, wireframes, and a functioning frontend with simulated backend responses.

12.1. Obtaining the example materials for this chapter

12.2. Understanding relationships between data

12.3. Associating data using embedded JSON

12.4. Understanding Sails associations

12.5. Using services

12.6. Summary