-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
90 lines (88 loc) · 2.57 KB
/
main.js
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
// FaunaDB Javascript Importer //
// This tool/service should not be used in a production env //
// Follow the steps below to import your data //
//
const FaunadbImporter = () => {
const faunadb = require("faunadb");
const q = faunadb.query;
//
// Step 01 - Input your FaunaDB Database Secret //
//
const client = new faunadb.Client({ secret: "Your Secret Here" });
//
// Step 02 - Input your formatted data from Mr Data Converter so that each entry or potential document is an array //
//
const dataInputArray = [
[
"First Value in First Array",
"Second Value in First Array",
"Third Value in First Array",
],
[
"First Value in Second Array",
"Second Value in Second Array",
"Third Value in Second Array",
],
];
//
// For larger data arrays you may want to consider splitting them up //
//
/* const dataInputArrayAdditional = [
[
"First Value in First Additional Array",
"Second Value in First Additional Array",
"Third Value in First Additional Array",
],
];*/
//
// Create Documents in Fauna based on each array in dataInputArray //
//
const createDocumentImport = async () => {
for (var i = 0; i < dataInputArray.length; i++) {
client.query(
q.Create(q.Collection("Fauna DB Collection Name"), {
data: {
First_key: dataInputArray[i][0],
Second_key: dataInputArray[i][1],
Third_key: dataInputArray[i][2],
},
})
);
}
};
//
// Import Function for dataInputArrayAdditional if needed //
//
/*
const createDocumentImportAdditional = async () => {
for (var i = 0; i < dataInputArrayAdditional.length; i++) {
client.query(
q.Create(q.Collection("Fauna DB Collection Name"), {
data: {
First_key: dataInputArrayAdditional[i][0],
Second_key: dataInputArrayAdditional[i][1],
Third_key: dataInputArrayAdditional[i][2],
,
},
})
);
}
};*/
return (
<div>
<div>
<img
src="https://imgix.cosmicjs.com/803ccfa0-5ff4-11eb-ad8f-d1a7eae548e8-Header-Logo-01.svg"
alt="Logo"
></img>
</div>
<button onClick={createDocumentImport}>
Import everything in dataInputArray
</button>
<button onClick={createDocumentImportAdditional}>
Import everything in dataInputArrayAdditional if needed
</button>
</div>
);
};
export default FaunadbImporter;