Skip to content

Commit 0ae4539

Browse files
committed
chore: playground
1 parent 61513f6 commit 0ae4539

File tree

2 files changed

+56
-8
lines changed

2 files changed

+56
-8
lines changed

packages/nuxt/playground/pages/firestore-useDocument.vue

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,50 @@
11
<script setup lang="ts">
2-
import { doc, getDoc } from 'firebase/firestore'
2+
import {
3+
GeoPoint,
4+
doc,
5+
getDoc,
6+
serverTimestamp,
7+
setDoc,
8+
} from 'firebase/firestore'
39
import { useDocument, useFirestore, usePendingPromises } from 'vuefire'
410
import { ref } from 'vue'
511
12+
async function setupNestedDocument() {
13+
const configDoc = await getDoc(configRef)
14+
if (configDoc.exists()) {
15+
return
16+
}
17+
18+
for (let i = 0; i < 3; i++) {
19+
await setDoc(doc(db, 'todos', String(i)), {
20+
text: 'Todo ' + i,
21+
finished: false,
22+
created: serverTimestamp(),
23+
})
24+
await setDoc(doc(db, 'tweets', String(i)), {
25+
text: 'Tweet ' + i,
26+
created: serverTimestamp(),
27+
})
28+
}
29+
30+
await setDoc(configRef, {
31+
amount: 28,
32+
name: 'Eduardo',
33+
array: ['one', 'two'],
34+
object: {
35+
bar: 'baro',
36+
foo: 'foo',
37+
todo: doc(db, 'todos', '1'),
38+
},
39+
oneTweet: doc(db, 'tweets', '1'),
40+
time: serverTimestamp(),
41+
loc: new GeoPoint(48.8566, 2.3522),
42+
43+
todos: [doc(db, 'todos', '1'), doc(db, 'todos', '2')],
44+
tweets: [doc(db, 'tweets', '1'), doc(db, 'tweets', '2')],
45+
})
46+
}
47+
648
const db = useFirestore()
749
const configRef = doc(db, 'configs', 'jORwjIykFo2NmkdzTkhU')
850
// const itemRef = doc(db, 'tests', 'item')
@@ -27,22 +69,22 @@ onMounted(() => {
2769
isAllDoneFetching.value = true
2870
})
2971
})
72+
73+
setupNestedDocument()
3074
</script>
3175

3276
<template>
3377
<div>
3478
<p>config:</p>
3579
<p>finished: {{ isDoneFetching }}</p>
3680
<p>All finished: {{ isAllDoneFetching }}</p>
37-
<p>
38-
Revive check:
39-
</p>
81+
<p>Revive check:</p>
4082
<ul>
4183
<li>TimeStamp: {{ config?.time }}</li>
4284
<li>GeoPoint: {{ config?.loc }}</li>
4385
</ul>
4486

45-
<hr>
87+
<hr />
4688

4789
<pre>{{ config }}</pre>
4890
</div>

playground/tsconfig.config.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
2-
"extends": "@vue/tsconfig/tsconfig.node.json",
3-
"include": ["vite.config.*", "vitest.config.*", "cypress.config.*"],
2+
"extends": "@vue/tsconfig/tsconfig.json",
3+
"include": [
4+
"vite.config.*",
5+
"vitest.config.*",
6+
"cypress.config.*"
7+
],
48
"compilerOptions": {
59
"composite": true,
6-
"types": ["node"]
10+
"types": [
11+
"node"
12+
]
713
}
814
}

0 commit comments

Comments
 (0)