Linking

Now that Version 2 of the contact service supports two data formats: JSON for storing contacts and binary format for storing an image file associated with a contact, we need to ensure that these data formats are not mixed. In the previous section, Working with arbitrary data, the information stored for a contact was extended with an additional file entry in MongoDB that stored the binary representation of a JPEG image.

However, none of the JSON models in previously exposed routes, /v2/contacts or /v2/contacts/{primary-number}, adopted that change, and the image was exposed in a new route:/v2/contacts/{primary-number|}/image. That was done intentionally, and keeping backward compatibility was not the main reason for that decision. Mixing ...

Get RESTful Web API Design with Node.js - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.