-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy-result.html
More file actions
99 lines (86 loc) 路 2.63 KB
/
Copy pathcopy-result.html
File metadata and controls
99 lines (86 loc) 路 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<script src="./the-result.js"></script>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.5.2/firebase-app.js';
import { getAnalytics } from 'https://www.gstatic.com/firebasejs/10.5.2/firebase-analytics.js';
import {
getStorage,
ref,
getDownloadURL,
} from 'https://www.gstatic.com/firebasejs/10.5.2/firebase-storage.js';
import {
getFirestore,
collection,
getDocs,
doc,
writeBatch,
addDoc,
serverTimestamp,
collectionGroup,
query,
deleteField,
setDoc,
getDoc,
where,
connectFirestoreEmulator,
} from 'https://www.gstatic.com/firebasejs/10.5.2/firebase-firestore.js';
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: 'AIzaSyBwRPBNhCfGDLC8wdAkIlx9m5mba5gm_iA',
authDomain: 'viajarcomale.firebaseapp.com',
projectId: 'viajarcomale',
storageBucket: 'viajarcomale.appspot.com',
messagingSenderId: '207097887664',
appId: '1:207097887664:web:b0f038dd322c756f77b475',
measurementId: 'G-SGK9KS9BBN',
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const db = getFirestore(app);
// connectFirestoreEmulator(db, '127.0.0.1', 8080);
const storage = getStorage();
const theBatch = writeBatch(db);
result.forEach((item) => {
if (item.order === 1) {
item.is_highlight = true;
}
item.hashtags = [
item.country.replaceAll('-', ''),
item.city.replaceAll('-', ''),
];
item.hashtags_pt = [
item.country.replaceAll('-', ''),
item.city.replaceAll('-', ''),
];
item.createdAt = serverTimestamp();
theBatch.set(
doc(
db,
'/countries/' +
item.country +
'/cities/' +
item.city +
'/medias/' +
item.id
),
item,
{
merge: true,
}
);
console.log(item.id);
});
theBatch.commit();
</script>
</body>
</html>