Hi guys !
I’m actually trying to put some arrays in a collection, which will be a document fetch of an other collection. Perhaps, actually, im getting a traceback in console.
I don’t know why, it seems to be unable to load the collection. Here’s the code :
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
SimpleSchema.extendOptions(['autoform']);
Project = new Mongo.Collection('project');
Project.allow({
insert: function(userId, doc) {
return !!userId;
},
update: function (userId, doc) {
return !!userId;
},
});
// LOAD HERE OTHE COLLECTIONS
import { Partners } from '../partners/collection.js';
partnersLoad = Partners.find({}).fetch();
Project_Schema = new SimpleSchema ({
name: {
type: String,
label: "Name *"
},
subtitle: {
type: String,
label: "Subtitle *"
},
desc: {
type: String,
label: "Description",
optional: true
},
client: {
type: Array,
optional: true
},
"client.$": {
type: String,
label: "Client name",
allowedValues: Partners
},
state: {
type: String,
label: "State *",
allowedValues: ['To do', 'Doing', 'Done']
},
dateBegin: {
type: Date,
label: "Project beginning",
optional: true
},
dateEnd: {
type: Date,
label: "Project Ending",
optional: true
},
priority: {
type: String,
label: "Priority *",
allowedValues: ['Low', 'Normal', 'High']
},
owner: {
type: String,
label: "Owner *"
},
title: {
type: String,
label: "Title",
optional: true
}
});
Meteor.methods({
projectDelete: function(id) {
Project.remove(id)
},
});
Project.attachSchema(Project_Schema);
Here is the other collection :
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
SimpleSchema.extendOptions(['autoform']);
Partners = new Mongo.Collection('Partners');
Partners.allow({
insert: function(userId, doc) {
return !!userId;
}
});
PartnersSchema = new SimpleSchema ({
name: {
type: String,
label: "Partner name"
},
surname: {
type: String,
label: "Partner surname"
}
});
Meteor.methods({
partnersDeletePartners: function(id) {
Partners.remove(id)
},
});
Partners.attachSchema(PartnersSchema);
The traceback i’m actually getting :
W20190131-08:23:12.544(1)? (STDERR) throw error;
W20190131-08:23:12.544(1)? (STDERR) ^
W20190131-08:23:12.544(1)? (STDERR)
W20190131-08:23:12.544(1)? (STDERR) TypeError: Cannot read property 'find' of undefined
W20190131-08:23:12.544(1)? (STDERR) at collection.js (collections/standard/project/collection.js:21:25)
Does anyone dit it already ? What am i doing bad ? Thanks a lot in advance !
Happy coding anyway !
Brawcks