locations.js 426 B

12345678910111213141516171819202122
  1. const _ = require('lodash')
  2. const { init, Location } = require('../database')
  3. module.exports = async () => {
  4. await Location.upsert({
  5. name: 'Los Angeles',
  6. key: 'LAX'
  7. }),
  8. await Location.upsert({
  9. name: 'San Francisco',
  10. key: 'SFO'
  11. }),
  12. await Location.upsert({
  13. name: 'Las Vegas',
  14. key: 'LAS'
  15. })
  16. return _.chain(await Location.findAll())
  17. .map(o => [o.key, o])
  18. .fromPairs()
  19. .value()
  20. }