Try to get plant types from db and load to frontend.
This commit is contained in:
parent
3ae342ad3c
commit
829769501c
@ -1,3 +1,37 @@
|
|||||||
import { Meteor } from 'meteor/meteor';
|
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"});
|
||||||
@ -1,5 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Container, Row, Col} from 'react-bootstrap';
|
import { Container, Row, Col} from 'react-bootstrap';
|
||||||
|
import { plantTypes } from '/imports/api/plantTypes';
|
||||||
|
|
||||||
import AddPlant from './AddPlant'
|
import AddPlant from './AddPlant'
|
||||||
import Plants from './Plants'
|
import Plants from './Plants'
|
||||||
|
|||||||
@ -2,6 +2,5 @@ import { Meteor } from 'meteor/meteor';
|
|||||||
import { PlantTypesCollection } from '/imports/api/plantTypes';
|
import { PlantTypesCollection } from '/imports/api/plantTypes';
|
||||||
|
|
||||||
Meteor.startup(() => {
|
Meteor.startup(() => {
|
||||||
|
|
||||||
PlantTypesCollection.insert({plantType: "BAUM"});
|
});
|
||||||
});
|
|
||||||
Loading…
Reference in New Issue
Block a user