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

Need a function NotExists() for columns not present in MongoDB #1275

Open
merohitnishad opened this issue May 14, 2024 · 1 comment
Open

Comments

@merohitnishad
Copy link

I am using Prisma with MongoDB as the datasource and Go as the generator. Below is my setup:

datasource db {
    provider = "mongodb"
    url      = env("MONGO_URI")
}

generator db {
    provider = "go run github.com/steebchen/prisma-client-go"
}

model Company {
    id        String   @id @default(auto()) @map("_id") @db.ObjectId
    name      String
    address   String
    created_at DateTime @default(now())
    updated_at DateTime @updatedAt
    deleted_at DateTime?
}

Currently, the following query works only when the deleted_at column is present and is null in MongoDB:

var params []db.CustomerWhereParam
params = append(params, db.Customer.DeletedAt.IsNull())

However, I need support for a query where the deleted_at column does not exist in MongoDB, like this raw query:

{
  "deleted_at": { "$exists": false }
}

Proposed solution:

params = append(params, db.Customer.DeletedAt.NotExists())
@steebchen
Copy link
Owner

Yeah this is currently missing, I will look into this.

internal note: The field should be isset like in the JS client.

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

No branches or pull requests

2 participants