la flame
la flame
PPrisma
Created by la flame on 9/29/2024 in #help-and-questions
JSON Filtering on object key value inside array example from doc doesn't work
model Test { id String @id @default(uuid()) @db.Uuid data Json }
await db.Test.create({data: {data: [{petName:"Claudine"}, {petName: "Sunny"}]}})
{ id: 'eb4fd0ac-2039-4e25-99bf-754573af3622', data: [ { petName: 'Claudine' }, { petName: 'Sunny' } ] }
await db.Test.create({data: {data: [{petName:"Nanna"}]}})
{ id: '5810d1c1-7ca9-4489-840a-dc3eae5db572', data: [ { petName: 'Nanna' } ] }
await db.Test.findMany({where: {data: {path: ["$[*].petName"], equals: "Claudine"}}})
[]
await db.Test.findMany({where: {data: {path: ["$[*].petName"], array_contains: "Claudine"}}})
How to make it work? clientVersion: '5.20.0'
1 replies
PPrisma
Created by la flame on 4/24/2024 in #help-and-questions
[MongoDB] dup key: { itemId: null }, labels: {}
Error: MongoDB error
Kind: Command failed: Error code 11000 (DuplicateKey): Index build failed: 83c54d6a-ffb6-44a5-8c6e-4ada6aa59ad6: Collection db.Collection ( 3fb85909-5e6c-4151-9a94-d99bdc225628 ) :: caused by :: E11000 duplicate key error collection: db.Collection index: Collection_itemId_key dup key: { itemId: null }, labels: {}
0: schema_core::state::SchemaPush
at schema-engine/core/src/state.rs:433
Error: MongoDB error
Kind: Command failed: Error code 11000 (DuplicateKey): Index build failed: 83c54d6a-ffb6-44a5-8c6e-4ada6aa59ad6: Collection db.Collection ( 3fb85909-5e6c-4151-9a94-d99bdc225628 ) :: caused by :: E11000 duplicate key error collection: db.Collection index: Collection_itemId_key dup key: { itemId: null }, labels: {}
0: schema_core::state::SchemaPush
at schema-engine/core/src/state.rs:433
Started getting this error for no reason, because I made aggregate and found no itemId with count > 1
3 replies
PPrisma
Created by la flame on 3/15/2024 in #help-and-questions
Prisma(postgres) stuck at `where: {assets: {none: {}}}`
I understand that the query is tight. But isn't there a way to do it? I have only ~1m records in assets. My goal is to get entity where assetsCount = 0(without raw queries); For example this query works lightning fast.
SELECT "entityId", COUNT(*) AS "count" FROM "Asset" GROUP BY "entityId" ORDER BY count;
SELECT "entityId", COUNT(*) AS "count" FROM "Asset" GROUP BY "entityId" ORDER BY count;
I'm asking if I'm doing things wrong or over-complicated. I'm not count this as prisma problem:heart:
1 replies