Closed neurosoup closed 8 years ago
Sorry,
seems to be a Mongo.Collection inheritance problem. Something has changed since the meteor 1.4.2 and I can't extend from Mongo.Collection as before.
I Close the issue.
For the benefit of the next person to wind up here by searching the error message: in my case, the issue was that my SimpleSchema
was the one out of aldeed:simple-schema
, as opposed to the one out of simpl-schema
as it should.
Here is what I did to fix my own symptom:
SimpleSchema
in my source codeimport SimpleSchema from "simpl-schema";
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
Since the 1.4.2 meteor update the attachSchema function leads to this error :
allow-deny.js:477Uncaught TypeError: Cannot read property 'insert' of undefined
Here is the code calling the attachSchema function : const Clusters = new ClustersCollection('clusters') Clusters.attachSchema(Schemas.Clusters)
The cluster collection extends a CollectionBase class wich is defined as follow
` export default class CollectionBase extends Mongo.Collection {
constructor(collectionName) { super(collectionName)
}
beforeInsert(doc) { }
afterInsert(doc) { }
beforeUpdate(selector, modifier, options) { }
afterUpdate(selector, modifier, options) { }
update(selector, modifier, options, callback) {
try { this.beforeUpdate(selector, modifier, options)
const res = super.update(selector, modifier, options, callback) if (res.insertedId) { const doc = super.findOne(res.insertedId) this.afterInsert(doc) } else { this.afterUpdate(selector, modifier, options) } return res } catch (e) { Logger.error(e) throw e } }
insert(doc, callback) { try { this._c2._simpleSchema.clean(doc) this.beforeInsert(doc) const res = super.insert(doc, callback) doc._id = res this.afterInsert(doc) return doc._id } catch (e) { Logger.error(e) throw e } }
}`
I'm trying to investigate further.
Thanks