Here's the scenario, but only with relevant fields and objects.An API provides an array of offers. Example:[{ market: "store_a", product_id: 1, ... }, { market: "store_b", product_id: 1, ... }]Offers are exposed for other resources, too.The clients want to display a market logo and market name.Now, the market metadata could be added to the mobile clients, but that would mean releasing a new mobile version each time a new market is added. This is no good. Rather than send out N offers and duplicate the logo URI and market name every time, the idea is to expose the markets in a separate route so clients can cache them, then look them up by slug.So, assuming we have decided on a route that allows the client to cache the market metadata (ex: GET /foo/markets => {store_a: { name: "Store A", image_uri: "https://ex.path/jpg" }, ...} ) and each market has two or three additional properties not to be exposed via API (ex: { store_a: { name: "Store A", image_uri: "https://ex.path/jpg", extneral_id: 99, otherprop: "ffff"} )...How would you manage the metadata?Here are some ideas:Store it all in a JSON or plain JS file; serve it up as a static JSON fileDo as above but use it for other metadata the app might needCreate a "markets" table that will never contain more than a dozen recordsCreate some "admin" or "app settings" table in postgres and manage them thereWhat do you think?Thanks in advance.Edit: The market slug is used by other models/tables, too, if that matters.
Submitted January 22, 2020 at 01:44AM by mannotbear
No comments:
Post a Comment