Try to get plant types from db and load to frontend.

This commit is contained in:
Andrés Uribe Stengel 2020-07-09 16:29:50 +02:00
parent 3ae342ad3c
commit 829769501c
3 changed files with 38 additions and 4 deletions

View File

@ -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"});

View File

@ -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'

View File

@ -2,6 +2,5 @@ import { Meteor } from 'meteor/meteor';
import { PlantTypesCollection } from '/imports/api/plantTypes';
Meteor.startup(() => {
PlantTypesCollection.insert({plantType: "BAUM"});
});
});