Created
February 5, 2022 15:21
-
-
Save kazuooooo/dd45f4014951e4f98ca34d043c1c462e 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