Nik
PPrisma
•Created by seromine on 5/6/2024 in #help-and-questions
[Prisma] Nested create with 2 levels of related records
4 replies
PPrisma
•Created by seromine on 5/6/2024 in #help-and-questions
[Prisma] Nested create with 2 levels of related records
4 replies
PPrisma
•Created by Nik on 4/17/2024 in #help-and-questions
prisma aggregateRaw, how to parse Date back to javascript date, and other special types,
2 replies
PPrisma
•Created by Nik on 4/15/2024 in #help-and-questions
@unique on optional field
THE SOLUTION
What Prisma should be doing is setting Sparse = true on any index of an optional @unique field
But I am having to manually remember to do this for every index from an optional @unique
If we mark an OPTIONAL field
foo
@unique, run:
db.collection.createIndex( { foo: 1 }, { unique:true, sparse: true } )
If we mark a REQUIRED field foo
@unique, run:
db.collection.createIndex( { foo: 1 }, { unique:true )
^ This is all prisma would have to do, currently it runs the second in both cases20 replies
PPrisma
•Created by Nik on 4/15/2024 in #help-and-questions
@unique on optional field
THE PROBLEM
OPTIONAL @unique indexes are erroring with duplicate
null/undefined
values.
This means that two records that omit an optionally @unique field will clash20 replies
PPrisma
•Created by Nik on 4/15/2024 in #help-and-questions
@unique on optional field
they're not marked sparse / partial which causes the issue.
20 replies
PPrisma
•Created by Nik on 4/15/2024 in #help-and-questions
@unique on optional field
In mongo / mongo drivers I can ignore null values like this.
20 replies
PPrisma
•Created by Nik on 4/15/2024 in #help-and-questions
@unique on optional field
ty for the help
20 replies
PPrisma
•Created by Nik on 4/15/2024 in #help-and-questions
@unique on optional field
am I missing something?
20 replies
PPrisma
•Created by Nik on 4/15/2024 in #help-and-questions
@unique on optional field
the issue is that fundamentally the relationship is one to one, and I'd prefer not to hack it with a many-many relationship that isn't accurate
20 replies
PPrisma
•Created by Nik on 4/15/2024 in #help-and-questions
@unique on optional field
So a player can be created without a user (witness another player ingame) and a user without a player (hasn't played a game yet)
20 replies
PPrisma
•Created by Nik on 4/15/2024 in #help-and-questions
@unique on optional field
So they have to be optional on both sides.
20 replies
PPrisma
•Created by Nik on 4/15/2024 in #help-and-questions
@unique on optional field
that's actually not the case here. A user is tied to whether they've signed in. And a player is only linked/created when they start their first game.
Both are optional
20 replies
PPrisma
•Created by Nik on 4/7/2024 in #help-and-questions
Update nested field in composite types
I understand the type-safety argument but I'd much rather have the option to use a mongoose-type selector with a throw if something goes wrong
3 replies