-
Notifications
You must be signed in to change notification settings - Fork 77
/
add_data.js
116 lines (109 loc) · 3.17 KB
/
add_data.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const weaviate = require("weaviate-client");
// importing data from json file
var data = require('./plant_info.json');
//setting up client
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
//if schema having class name Plants already exists deleting it
client.schema
.classDeleter()
.withClassName('Plants')
.do()
.then(res => {
console.log(res);
})
.catch(err => {
console.error(err)
});
// Creating Schema
var plant_class_schema = {
"class": "Plants",
"description": "Various Info about plants",
"properties": [
{
"name": "title",
"dataType": ["string"],
"description": "The name of the plant",
},
{
"name": "alternateName",
"dataType": ["string"],
"description": "The alternate name of the plant",
},
{
"name": "sowInstructions",
"dataType": ["string"],
"description": "Sowing instruction of the plant",
},
{
"name": "spaceInstructions",
"dataType": ["string"],
"description": "Spacing instruction of the plant",
},
{
"name": "harvestInstructions",
"dataType": ["string"],
"description": "Harvesting instruction of the plant",
},
{
"name": "compatiblePlants",
"dataType": ["string"],
"description": "Compatible with (can grow beside) of the plant",
},
{
"name": "avoidInstructions",
"dataType": ["string"],
"description": "Avoiding instruction of the plant",
},
{
"name": "culinaryHints",
"dataType": ["string"],
"description": "Culinary instruction of the plant",
},
{
"name": "culinaryPreservation",
"dataType": ["string"],
"description": "Culinary Preservation of the plant",
},
{
"name": "url",
"dataType": ["string"],
"description": "url link of the plant",
},
{
"name": "imageLinks",
"dataType": ["string"],
"description": "Image link of the plant",
},
]
}
//Adding data of 15 plants
for(let i=0;i<data.length;i++)
{
plant_object = {
'title': data[i]['Name'],
'alternateName': data[i]['alternateName'],
'sowInstructions':data[i]['sowInstructions'],
'spaceInstructions': data[i]['spaceInstructions'],
'harvestInstructions': data[i]['harvestInstructions'],
'compatiblePlants':data[i]['compatiblePlants'],
'avoidInstructions': data[i]['avoidInstructions'],
'culinaryHints': data[i]['culinaryHints'],
'culinaryPreservation':data[i]['culinaryPreservation'],
'url': data[i]['url'],
'imageLinks': data[i]['image-links']
}
client.data
.creator()
.withClassName('Plants')
.withProperties(plant_object)
.do()
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
}