Meteor-Community-Packages / meteor-collection-hooks

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

Problem with custom "_id" in "before.insert()". #173

Closed thearabbit closed 8 years ago

thearabbit commented 8 years ago

Problem with custom "_id" in "before.insert()".

// fixture
var locatData = {........}; // don't have _id field
var locatId = Location.insert(locatData);
console.log('id after insert: ' + locatId);

// hook
Location.before.insert(function (userId, doc) {
    doc._id = '0001';
});

// Result
id after insert: random id
// It should be '0001'

Please help me.

matb33 commented 8 years ago

Duplicate of https://github.com/matb33/meteor-collection-hooks/issues/159