Created
February 5, 2022 15:24
-
-
Save kazuooooo/e13f8aa8a85e539ea1d2a382ba21d792 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { doc, getFirestore } from "firebase/firestore" | |
import { defineStore } from "pinia" | |
type ExampleDoc = { | |
name: string, | |
age: number | |
} | |
export type State = { | |
docData: ExampleDoc | null, | |
} | |
export const useExampleStore = defineStore('expamle', { | |
state: (): State => { | |
return { | |
docData: null, | |
} | |
}, | |
actions: { | |
async setup() { | |
// Get Document reference | |
const store = getFirestore() | |
const docRef = doc(store, 'Examples/id') | |
// Do the magic | |
this.sync('docData', docRef) | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment