Meteor-Community-Packages / meteor-collection-hooks

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

don't work on "METEOR@1.5-beta.13" #219

Closed thearabbit closed 7 years ago

thearabbit commented 7 years ago

I tried to use this in METEOR@1.5-beta.13, but don't work.

namirsab commented 7 years ago

Well, let's wait till 1.5 release is out and we can check if it works there. thanks for the info

namirsab commented 7 years ago

Can you anyway provide more informaton about what "Don't work" means?

thearabbit commented 7 years ago

my structure

// imports/api/posts/posts.js
import {Mongo} from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import {Tracker} from 'meteor/tracker';

const Posts = new Mongo.Collection('posts');
Posts.schema = new SimpleSchema({
    name: {
        type: String,
  ...........
Posts.attachSchema(Posts.schema);

export default Posts;
----------------------
// imports/api/posts/server/hook.js (imported in server)
import 'meteor/matb33:collection-hooks';

import Posts from '../posts';

 Posts.before.insert(function (userId, doc) {
     console.log('hook running');

 });

But don't work when I tried insert data

namirsab commented 7 years ago

I think you are misusing the package.

Can you show me your .meteor/versions file?

The package should be added globally as a meteor package, and you don't need to import it in any file. This package is changing the Mongo.Collection (extending it with the functionality)

thearabbit commented 7 years ago

Oh, I find the error. Bc I use Collection.upsert!!!