Skip to content

URGENT: matb33:collection-hooks not compatible with Meteor 3.3.1 #321

@mcorbelli

Description

@mcorbelli

Describe the bug
After upgrading to Meteor 3.3.1, the matb33:collection-hooks library no longer works as expected. Using hooks on a collection results in the following error:

TypeError: Cannot read properties of undefined (reading 'insert')

To Reproduce
Steps to reproduce the behavior:

  1. Create a new collection with matb33:collection-hooks and idGeneration: "MONGO".
  2. Add a before.insert hook, e.g.:
class AggregatedOrdersCollection extends Mongo.Collection {
  constructor(name, options) {
    super(name, options);
  }

  findOneByAggregateId = async (aggregate_id) => {}
}

const AggregatedOrdersDB = new AggregatedOrdersCollection(Collections.AGGREGATED_ORDERS, {
  idGeneration: "MONGO",
});

AggregatedOrdersDB.before.insert((user_id, doc) => {
  const now = dayjs().toDate();

  doc["dates"] = {
    created_at: now,
    updated_at: now,
  };
});
  1. See the error in the console.

Expected behavior
The before.insert hook should be called correctly, allowing modification of the document before insertion.

Screenshots
Image

Additional context
It seems the issue may be caused by the updated Mongo driver in Meteor 3.3.1. The library might require an update to be compatible with the new mongo module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions