Replaces MongoDB PSL `field(sort: Asc | Desc)` with `sort(field, Asc |
Desc)`, preserving existing index behavior.
## Changes
- Use a single sort function in `@@index`, `@@unique`, and
`@@textIndex`, with model-aware field validation and completion.
- Preserve the context required by nested function arguments in the
shared PSL attribute framework.
- Update regression tests, documentation, example schemas, and example
migration snapshots.
- Add [app upgrade
instructions](upgrade-instructions/pending/mongo-index-sort-function/app/instructions.md)
for current schemas, migration snapshots, and documentation.
## Why
A stable function name makes the field an explicit argument instead of
generating a function signature for every model field.
**Scope:** MongoDB syntax only. Plain fields and wildcard syntax remain
supported. The old syntax is rejected; null-ordering options are not
added. SQL syntax is unchanged.
## Validation
- 331 Mongo authoring tests and 1,357 parser tests passed.
- 59 language-server completion tests and 34 focused integration tests
passed.
- Four package typechecks, builds, and Biome checks passed.
- No old sort syntax remains in examples; diff checks and
upgrade-instruction coverage passed.
- Example applications were not run end-to-end.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* MongoDB index declarations support `sort(field, Asc)` and `sort(field,
Desc)`, with editor suggestions for fields and sort directions.
* **Bug Fixes**
* Index sorting now correctly handles mapped fields, compound indexes,
and text indexes.
* **Documentation**
* Updated MongoDB index guidance and examples to use the supported sort
syntax, and added instructions for updating existing schemas and
migration snapshots.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Co-authored-by: Steven McClankerton <tatarintsev@prisma.io>