Automattic / Automattic/mongoose
Make model operations wait on `Model.init()`?
- 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
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