Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): Support omit option to queries #389

Open
medz opened this issue Jun 4, 2024 · 0 comments
Open

feat(client): Support omit option to queries #389

medz opened this issue Jun 4, 2024 · 0 comments

Comments

@medz
Copy link
Owner

medz commented Jun 4, 2024

Protocol 1 (omit(true)):

{
      modelName: 'User',
      action: 'findMany',
      previewFeatures: ['omitApi'],
      args: { omit: { name: true } },
}

->

{
      "modelName": "User",
      "action": "findMany",
      "query": {
        "arguments": {},
        "selection": {
          "$composites": true,
          "$scalars": true,
          "name": false
        }
      }
 }

Protocol 2 (omit(false)):

{
      modelName: 'User',
      action: 'findMany',
      previewFeatures: ['omitApi'],
      args: { omit: { name: false } },
 }

->

{
      "modelName": "User",
      "action": "findMany",
      "query": {
        "arguments": {},
        "selection": {
          "$composites": true,
          "$scalars": true,
          "name": true
        }
      }
    }

Protocel 3 (omit + include):

{
      modelName: 'User',
      action: 'findMany',
      previewFeatures: ['omitApi'],
      args: { include: { posts: { omit: { title: true } } } },
    }

{
      "modelName": "User",
      "action": "findMany",
      "query": {
        "arguments": {},
        "selection": {
          "$composites": true,
          "$scalars": true,
          "posts": {
            "arguments": {},
            "selection": {
              "$composites": true,
              "$scalars": true,
              "title": false
            }
          }
        }
      }
    }

More see 👉 https://github.com/prisma/prisma/pull/23770/files#diff-ff0c0eab8c9ab531a46770b84e6254a67f0cf40fb9d4ceb1c5f7c17f497c1633

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant