diff --git a/imports/api/plantTypes.js b/imports/api/plantTypes.js index dda78b8..7003414 100644 --- a/imports/api/plantTypes.js +++ b/imports/api/plantTypes.js @@ -1,3 +1,37 @@ import { Meteor } from 'meteor/meteor'; -export const PlantTypesCollection = new Meteor.Collection('plantTypes'); +const PlantTypesCollection = new Meteor.Collection('plantTypes'); + +var plantTypesDocuments = PlantTypesCollection.find(); + +export var plantTypes = []; + +plantTypesDocuments.forEach((plantType) => { + plantTypes.push(plantType.plantType); +}); + +function createTypesString() { + var typesString = ""; + var arrayLength = plantTypes.length; + var cnt = 1; + plantTypes.forEach((plantType) => { + if (cnt === arrayLength) { + typesString = typesString + plantType + } else { + typesString = typesString + plantType + ", " + } + cnt++; + }); + + return typesString; +} + +var types = createTypesString(); + +console.log("TYPES: " + types); + +//PlantTypesCollection.insert({plantType: "BAUM"}); + +//const plantTypeVegetables = PlantTypesCollection.findOne({dirtType: "Humus"}); +//const plantTypeCacti = PlantTypesCollection.findOne({dirtType: "Sand"}); +//const plantTypeFlowers = PlantTypesCollection.findOne({dirtType: "Loam"}); \ No newline at end of file diff --git a/imports/ui/Settings.jsx b/imports/ui/Settings.jsx index a06b24f..20ba567 100644 --- a/imports/ui/Settings.jsx +++ b/imports/ui/Settings.jsx @@ -1,5 +1,6 @@ import React from 'react' import { Container, Row, Col} from 'react-bootstrap'; +import { plantTypes } from '/imports/api/plantTypes'; import AddPlant from './AddPlant' import Plants from './Plants' diff --git a/server/main.js b/server/main.js index dc53949..7d916af 100644 --- a/server/main.js +++ b/server/main.js @@ -2,6 +2,5 @@ import { Meteor } from 'meteor/meteor'; import { PlantTypesCollection } from '/imports/api/plantTypes'; Meteor.startup(() => { - - PlantTypesCollection.insert({plantType: "BAUM"}); -}); + +}); \ No newline at end of file