Skip to content

Commit cb529cd

Browse files
committed
chore: playground up
1 parent 556fd5e commit cb529cd

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

Diff for: firestore.rules

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ service cloud.firestore {
1919
allow read, write;
2020
}
2121

22+
match /playground/pinia-counter {
23+
allow read, write;
24+
}
25+
2226
match /{document=**} {
2327
allow read, write: if false;
2428
}

Diff for: playground/src/stores/counter.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ref, computed } from 'vue'
22
import { acceptHMRUpdate, defineStore } from 'pinia'
3-
import { doc, setDoc, updateDoc } from 'firebase/firestore'
3+
import { doc, setDoc, updateDoc, type DocumentData } from 'firebase/firestore'
44
import { useDocument, useFirestore } from 'vuefire'
55

66
export const useCounterStore = defineStore('counter', () => {
@@ -9,16 +9,17 @@ export const useCounterStore = defineStore('counter', () => {
99

1010
const db = useFirestore()
1111

12-
const countRef = doc(db, 'playground', 'pinia-counter').withConverter<number>(
13-
{
14-
toFirestore(n) {
15-
return { n }
16-
},
17-
fromFirestore(snapshot) {
18-
return snapshot.data().n as number
19-
},
20-
}
21-
)
12+
const countRef = doc(db, 'playground', 'pinia-counter').withConverter<
13+
number,
14+
DocumentData
15+
>({
16+
toFirestore(n) {
17+
return { n }
18+
},
19+
fromFirestore(snapshot) {
20+
return snapshot.data().n as number
21+
},
22+
})
2223

2324
useDocument(countRef, {
2425
target: count,

0 commit comments

Comments
 (0)