prisma-client-go icon indicating copy to clipboard operation
prisma-client-go copied to clipboard

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

Open merohitnishad opened this issue 1 year ago • 1 comments

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())

merohitnishad avatar May 14 '24 18:05 merohitnishad

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

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

steebchen avatar May 14 '24 18:05 steebchen