Mongodb array field in autoform select dropdown


#1

I have this in my lib folder

Subjects = new Mongo.Collection("subjects");
if(Meteor.isClient){
	Tracker.autorun(function(){
		Meteor.subscribe("subject.list");
	});
};

Server

Meteor.pubish({
    'subject.list': function(){
		let userId = this.userId;
		if(Roles.userIsInRole(userId, ['admin', 'staff','student'])){
			let subjectList = Subjects.find({"_id":"default"});	
				if(subjectList){
					return subjectList;
				}
		}
		return this.ready();
	},
})

So, I’m using subjects like this in Autoform as allowedValues

subjectArray = Subjects.findOne().subjects;
...
allowedValues: subjectArray, //undefined
...

console.log(Subjects.findOne().subjects;) in the browser’s console prints correct subjectArray but subjectArray variable always return undefined. Also, setting subjectArray = [“Physics”,“Mathematics”,“Chemistry”] worked.

Any help will be appreciated. Thanks