feat(database): disable eager collection creation for all schemas#1553
feat(database): disable eager collection creation for all schemas#1553ChrisPdgn wants to merge 3 commits into
Conversation
Set autoCreate and autoIndex to false on every Mongoose schema so collections are only created on first write or explicit index creation. Co-authored-by: Cursor <[email protected]>
|
@ioanniskemerlis 's comment in #1554 is related to this branch too |
With autoIndex disabled, field-level unique/index definitions and single-field indexes moved onto fields by SchemaConverter were not being created on fresh databases. Create them explicitly from the compiled Mongoose schema while skipping the default _id index so schemas without other indexes remain lazy. Co-authored-by: Cursor <[email protected]>
Align explicit field-index creation with MongoDB IndexSpecification typing so the database module builds on v0.16.x. Co-authored-by: Cursor <[email protected]>
Summary of changesThis PR disables eager MongoDB collection creation in the Mongoose adapter while preserving correct index behavior on fresh databases. 1. Lazy collection creationIn
This stops Mongoose from creating empty collections at schema registration time. Collections are created lazily on first write, or when an index is explicitly created. 2. Explicit field-level index creationDisabling To fix that, Important safeguards:
Expected behavior
No Conduit schema migration is expected; |
Summary
autoCreate: falseandautoIndex: falseon every Mongoose schema in the database adapter, not just views.createIndexes()during schema registration.Test plan
findMany/findOneagainst a schema whose collection has not been created yet and confirm empty results are returned without errors.