Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hooks don't get called #4

Open
ghost opened this issue Mar 5, 2015 · 5 comments
Open

Hooks don't get called #4

ghost opened this issue Mar 5, 2015 · 5 comments

Comments

@ghost
Copy link

ghost commented Mar 5, 2015

This is my helper

Posts.before.insert(function (userId, doc) {
    doc.createdAt = moment().toDate();
});

and schema

PostsSchema = new SimpleSchema({
    title: {
        type: String
    },
    createdAt: { // this is required
        type: Date
    }
});

This works fine when i am inserting doc on client side. But when using the factor the hooks don't get called before insert.

Factory.define('post', Posts, {
    title: function () {
        return Fake.word();
    }
});
@dburles
Copy link
Collaborator

dburles commented Mar 5, 2015

Is the hook and Factory defined on both server and client?

@ghost
Copy link
Author

ghost commented Mar 5, 2015

My factory is only defined on the server inside a meteor.startup function. My hooks are defined on both.

@dburles
Copy link
Collaborator

dburles commented Mar 5, 2015

Might you have a simple repro project I can use to debug?

@ghost
Copy link
Author

ghost commented Mar 6, 2015

Here is the Repo

To make it and easy for you

My Factory
Hooks

_Note_I have base schema(Combining schema) and base hooks.

@dburles
Copy link
Collaborator

dburles commented Mar 6, 2015

Sorry I mean something like what's described here. That'll make it easier for me to have a look into it for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant