Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Vueのバックエンドとして Firebaseを使った話

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Jungmo Kang Jungmo Kang
October 05, 2017

Vueのバックエンドとして Firebaseを使った話

Avatar for Jungmo Kang

Jungmo Kang

October 05, 2017
Tweet

Other Decks in Programming

Transcript

  1. VueͱFirebaseͷ࿈ܞ • VueFireͷ௥Ճ • VueFireΛొ࿥ • Firebaseͱ࿈ܞ $ npm install

    firebase vuefire --save import Vue from 'vue' import VueFire from 'vuefire' import App from './App' Vue.use(VueFire) import Firebase from 'firebase' let config = { apiKey: "...", authDomain: "...", databaseURL: "...", storageBucket: "...", messagingSenderId: "..." }; let app = Firebase.initializeApp(config) let db = app.database()
  2. Realtime Database event trigger ίʔυ͸͜Μͳײ͡ export const changedCustomerInfo = functions.database.ref(`/${DB_ROOT}/customers/

    {customerKey}`) .onWrite(databaseEvents.OnCustomerChanged) export const changedAreas = functions.database.ref(`/${DB_ROOT}/areas/{areaKey}`) .onWrite(databaseEvents.OnAreasChanged) export const changedShops = functions.database.ref(`/${DB_ROOT}/shops/{shopKey}`) .onWrite(databaseEvents.OnShopsChanged) export const changedDevices = functions.database.ref(`/${DB_ROOT}/devices/{deviceKey} `) .onWrite(databaseEvents.OnDevicesChanged) export const changedUsers = functions.database.ref(`/${DB_ROOT}/customers/ {customerId}/users/{userId}`) .onWrite(databaseEvents.OnUsersChanged) export const changeContracts = functions.database.ref(`/${DB_ROOT}/contracts/ {contractKey}`) .onWrite(databaseEvents.OnContractChanged)
  3. ෳ਺ͷFirebaseΛϩʔυ const config = { apiKey: …, authDomain: …, databaseURL:

    … } const secondaryConfig = { apiKey: …, authDomain: …, databaseURL: … } const firebaseApp = firebase.initializeApp(config) const secondaryFirebaseApp = firebase.initializeApp(secondaryConfig, 'secondary')
  4. σʔλ͸ϑϥοτʹʂ customers -KnrCVAqhTQ33fGkz50s shops -KnrCVBHeSztSd86_CVI: true ... shops -KnrCVBHeSztSd86_CVI customerKey:

    -KnrCVAqhTQ33fGkz50s devices -KnXFP1dGQoLsu4dzran: true ... devices -KnXFP1dGQoLsu4dzran customerKey: -KnrCVAqhTQ33fGkz50s shopKey: -KnrCVBHeSztSd86_CVI name: '