prisma / prisma/orm

`Json` ordering

Open
#9,130 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/feature topic: Json topic: orderBy / sorting
Dominant language
TypeScript
Stars
47.6k
Forks
2.5k
Avg merge
21h 59m
Merged PRs (30d)
95

Description

Problem

The "json ordering" feature is required. This is, in my opinion, a fairly basic feature. People who are introduced to prisma for the first time will discover that this function does not exist and will be perplexed, as I was.

Suggested solution

const getUsers = await prisma.user.findMany({
  orderBy: {
    extendedPetsData: {
        path: ['pet2', 'petName'],
        direction: 'asc',
    },
  },
})

Alternatives

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named in the issue. Start by examining the requested orderBy example and the project's database query paths; done means JSON fields can be ordered by a nested path in ascending or descending order.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.