Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Rapid data modeling for mobile – Connect Silicon Valley 2017

298 views

Published on

Speaker: Aaron Benton, Shop.com

Join Aaron Benton to hear how SHOP.COM's mobile team uses FakeIt with Couchbase and Sync Gateway to create and sync datasets with handheld devices.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Rapid data modeling for mobile – Connect Silicon Valley 2017

  1. 1. Rapid Data Modeling and Testing AARON BENTON
  2. 2. community.couchbase.com
  3. 3. + Couchbase Server Couchbase Mobile
  4. 4. Use Cases • Mobile • Caching • User Tracking • Media • Short Urls • Products • Session Management
  5. 5. • How is data represented? • How are models communicated? • How are models documented? • How are data types defined?
  6. 6. First, solve the problem. Then, write the code.“ ” - John Johnson
  7. 7. Data Modeling
  8. 8. Conceptual Data Modeling Entity Names Entity Relationships Users Products Line Items Orders
  9. 9. Logical Data Modeling Entity Names Entity Attributes Entity Relationships Users User ID (PK) Username Password First Name Last Name Address City State Zip Code Country Email Phone Orders Order ID (PK) Order Number User ID (FK) Order Date Address City State Zip Code Country Phone Email Credit Card Expiration Date Order Line Items Order ID (FK) Product ID (FK) Quantity Total Products Product ID (PK) Product Name Description Price
  10. 10. Physical Data ModelingEntity Names -> Table NamesEntity Attributes -> Field NamesEntity Relationships -> Keys Primary / Foreign Keys Data Types
  11. 11. NoSql Modeling • How do you represent a model? • What tools do you use? • How do you show relationships? • Does code define the model? • What key patterns should be used?
  12. 12. JSON
  13. 13. JSON Schema
  14. 14. YAML
  15. 15. Now What?
  16. 16. START DEVELOPMENT!
  17. 17. FAKE DATA
  18. 18. WASTED TIME
  19. 19. Fake Data Generators• FakerJS • ChanceJS • json-generator.com • objgen.com/json • mockaroo.com • jsonschema.net
  20. 20. Relationships are Hard
  21. 21. FakeIT
  22. 22. Fakeit • CLI Tool inspired by Swagger • Models defined in YAML • Generates JSON, CSON, YAML, CSV • Exports to Couchbase, Sync Gateway, Zip, Console
  23. 23. Fakeit Data • Exposes FakerJS and ChanceJS • Custom Build Functions w/ Pre and Post • Multiple Models • Dependencies • Definitions *fakeit is for structure, cbworkloadgen is for sizing
  24. 24. npm install fakeit -g
  25. 25. Original YAML Model
  26. 26. Simple Model 28 Data Attribute
  27. 27. Console Output
  28. 28. File Output
  29. 29. Output Formats
  30. 30. CSV Output
  31. 31. Zip Archive
  32. 32. Couchbase
  33. 33. What about Mobile…?
  34. 34. Sync Gateway
  35. 35. Channel Property
  36. 36. Sync Gateway with Auth
  37. 37. How does it Work?
  38. 38. Property Data: value • A static value to be used • Executed at build time fake • A FakerJS template string • Executed at build time pre_build • Function body used to initialize a property • Property is set to the returned value build • Function body used to set a property • Property is set to the returned value post_build • Function body used to manipulate a property after it has been set • Property is set to the returned value pre_run • Function body that is executed before any models are generated post_run • Function body that is executed before after all models have been generated
  39. 39. Flow Model Pre_RUN Model PRE_BUILD Initialize Property Value (EACH) Start Document Run Property PRE_BUILD + BUILD (EACH) PROPERTY POST_BUIL D (EACH) MODEL POST_BUIL D MODEL POST_RUN
  40. 40. Flow
  41. 41. Flow
  42. 42. Multiple Models
  43. 43. Multiple Models
  44. 44. Dependencie s Users Products Reviews Orders
  45. 45. Dependencies
  46. 46. Dependencies
  47. 47. Dependencies with Single Output
  48. 48. Definitions
  49. 49. Definitions
  50. 50. continents.json countries.csv Inputs
  51. 51. continents.json countries.csv Inputs
  52. 52. Require
  53. 53. Require
  54. 54. Seeds
  55. 55. Seeds
  56. 56. JS API
  57. 57. JS API Options
  58. 58. How we use FakeIt• YAML models store in the repository • Make commands to generate data • Docker Compose: • Couchbase • Sync Gateway • Testing / QA
  59. 59. Demos
  60. 60. Fakeit Examples• Contacts • Ecommerce • Flat • Flight Data • Music • Simple • Social bit.ly/fakeit-examples
  61. 61. Questions?
  62. 62. HOW TO CONTACT MEDon’t hesitate to contact with me. I will be happy to answer your questions. TWITTER: @bentonam github.com/bentonam EMAIL: aaron@shop.com Thank You!

×