Closed solo999 closed 4 years ago
I've brougt this up in meteor/meteor's 1.6.1 thread. This is because Mongo and/or Minimongo is now using es6 classes. I've started to test some possible solutions in a branch named meteor-1.6.1.
This is a very crucial task. We need this solved soon. Are you on the right track? Do you need help?
I tried to change Mongo.Collection.appy to new Mongo.Collection without much luck when I looked at this last time. Maybe it's related to meteor/meteor#9531. Maybe I'll have time this weekend to look at this, but i will happily accept a PR.
This should be fixed with https://github.com/meteor/meteor/commit/b06a6af335427d57ac47963a6989ced482f5e5f9#comments and I guess that will be in the next RC of Meteor 1.6.1.
after upgrade to rc7, collection hooks cause no build error, but
client side undefined
server side is okay
const { Mongo } = global;
const Activities = new Mongo.Collection('activities');
console.log(Activities.before)
Activities.before.find(function beforeFind(userId, selector) {
const user = Meteor.users.findOne(userId);
const isAdmin = user && user.role === 'content-admin';
if (!isAdmin && !Object.prototype.hasOwnProperty.call(selector, 'isDeleted')) {
selector.isDeleted = { $ne: true };
}
if (!isAdmin && !Object.prototype.hasOwnProperty.call(selector, 'isArchived')) {
selector.isArchived = { $ne: true };
}
});
export default Activities;
@crapthings That example works for me in 1.6.1-rc.7
(that is, Activities.before.find
is defined & works). Can you make a small reproduction that I could play with?
If this is working with 0.8.4
but not 0.9.0-rc4
I'm thinking maybe this https://github.com/matb33/meteor-collection-hooks/commit/b94c3c0c4230c2c7c5624dd1f790305d0ba1215d commit is what's causing the problem.
i've checked version file, its 0.8.4. matb33:collection-hooks@0.8.4
i will try a new project see if it works.
its working with a new project.
after move collection hooks to the bottom of the packages, it works. still don't know which plugin cause this.
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
feit:server-picker
meteor-base # Packages every Meteor app needs to have
mongo # The database Meteor supports right now
static-html
reactive-var # Reactive variable for tracker
jquery # Helpful client-side library
tracker # Meteor's client-side reactive programming library
standard-minifier-css # CSS minifier run for production mode
standard-minifier-js # JS minifier run for production mode
ecmascript # Enable ECMAScript2015+ syntax in app code
meteorhacks:kadira
accounts-password
kadira:flow-router
dburles:collection-helpers
aldeed:simple-schema
aldeed:collection2
reywood:publish-composite
check
tmeasday:publish-counts
maximum:server-transform
#meteorhacks:fast-render
stylus
http
accounts-base
lvfang:aggregate
random
meteorhacks:zones
meteorhacks:unblock
peerlibrary:control-mergebox
ccorcos:subs-cache
crapthings:cao
lvfang:intl
shell-server
dynamic-import
matb33:collection-hooks
vsivsi:file-collection
@crapthings I had issues with the maximum:server-transform
package and removed it from my project. It didn't help to move matb33:collection-hooks
to the bottom.
+1 had to rollback to meteor 1.6.0.1 because of undefined errors in find property. Is there any fix for this?
I had a patch for an unrelated issue I was facing, not sure if it might shed light on the issues here. https://github.com/matb33/meteor-collection-hooks/pull/240
@aramk , it fixes the undefined errors for me but I am having some other issues that might not be related to this case and I do not have enough time to continue testing, so I am reverting the patch 1.6.1.1 back to 1.6.0.1, but so far it seems you are on the right path!
Any chance of publishing this soon?
Fixed with @aramk PR in 0.9. Thanks a lot @aramk !
Happy to help!
matb33:collection-hooks (0.8.4) TypeError: Class constructor Collection cannot be invoked without 'new' at new ns.Collection (packages/matb33_collection-hooks.js:275:27)