Automattic / Automattic/mongoose

Make model operations wait on `Model.init()`?

Open
#8,815 0 comments 1 reaction 0 assignees View on GitHub
backwards-breaking
Dominant language
JavaScript
Stars
27.5k
Forks
4k
Avg merge
2d 7h
Merged PRs (30d)
35

Description

Re: #8786 , other issues.

Testing transactions, `unique` constraints, change streams, etc. is confusing because you need to call `Model.init()` under the hood to wait for indexes to build and for Mongoose to create the collection (if you set the `autoCreate` option). It would be great if we could make Mongoose automatically create collections for models and block `startSession()` and `watch()` until the collection is created.

Also see #8814

Contributor guide

Open the contributing guide

Research direction

Start by reading the discussion in #8786 and #8814, then trace the existing Model.init(), startSession(), and watch() entry points. Define how automatic collection creation and waiting should interact with indexes, transactions, unique constraints, and change streams; done means those operations no longer require callers to invoke Model.init() first.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, node.js
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.