Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks
https://atmospherejs.com/matb33/collection-hooks
MIT License
658 stars 90 forks source link

Error in matb33:collection-hooks when upgrading meteor to 1.6.1-rc.1 #234

Closed solo999 closed 4 years ago

solo999 commented 6 years ago

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)

zimme commented 6 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.

theodorDiaconu commented 6 years ago

This is a very crucial task. We need this solved soon. Are you on the right track? Do you need help?

zimme commented 6 years ago

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.

zimme commented 6 years ago

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.

crapthings commented 6 years ago

after upgrade to rc7, collection hooks cause no build error, but

client side undefined

image

server side is okay

image

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;
benjamn commented 6 years ago

@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?

zimme commented 6 years ago

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.

crapthings commented 6 years ago

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.

crapthings commented 6 years ago

its working with a new project.

crapthings commented 6 years ago

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
lmachens commented 6 years ago

@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.

kwuite commented 6 years ago

+1 had to rollback to meteor 1.6.0.1 because of undefined errors in find property. Is there any fix for this?

aramk commented 6 years ago

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

kwuite commented 6 years ago

@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!

hluz commented 6 years ago

Any chance of publishing this soon?

StorytellerCZ commented 4 years ago

Fixed with @aramk PR in 0.9. Thanks a lot @aramk !

aramk commented 4 years ago

Happy to help!