Hello,
I am new in WebDev, new in schema, meteor and mongoDB. I want to create a schema that has an autoValue that should load directly from the DB. So I need to convert the DB value into array so that I can access it as an array element for the allowedvalue. I have tried the above but it does not work. Please, advise:
my schema funciton and field:
function getClassification(classification) {
//return db.Classification.find({classification}).toArray();
var sportsArray = Sports.find({classification}).fetch(); // fetch() returns a collection as an array
console.log(sportsArray);
// convert sportArray into an array format autoForm can understand for selection options
var sportsOptions = sportsArray.map( function (obj) {
return {‘label’: obj.name, ‘value’: obj.name};
});
}
priority:{
type: String,
allowedValues: getClassification(priority),
defaultValue: ‘Normal’
},
I get an application error and my app does not restart. What can be the problem here?
Also, I need to read my database value and display them as Tab:
When I pass an array into this component, it work but when i pass my collection it does not work:
{this.props.categories.map((category, i) => {
// console.log(i);
// Return the element. Also pass key
return (<Tab key={i} label={category} />)
})}
</Tabs>
parent element:
import {categories} from ‘…/…/…/…/api/Collections/Categories’; // this my local array
import { Classification } from “…/…/…/…/api/Collections/Collections”; // this is my collection,
export default class Footer extends Component {
render(){
return (
<div>
<footer>
<h1> Footer comes Here !</h1>
<TabNavB categories={categories} />
</footer>
</div>
);
}
}
what is the correct way of doing this?