Created
February 18, 2022 16:05
-
-
Save millsp/ffd1ab8494818346a712105140faf529 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { PrismaClient } from ".prisma/client"; | |
/* | |
model CommentOptionalProp { | |
id String @id @default(auto()) @map("_id") @db.ObjectId | |
country String? | |
content CommentContent? | |
} | |
type CommentContent { | |
time DateTime @default(now()) | |
text String | |
upvotes CommentContentUpvotes[] | |
} | |
type CommentContentUpvotes { | |
vote Boolean | |
userId String | |
} | |
*/ | |
(async () => { | |
const prisma = new PrismaClient(); | |
/** | |
* create | |
*/ | |
// +1 | |
const comment1 = await prisma.commentOptionalProp.create({ | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment2 = await prisma.commentOptionalProp.create({ | |
data: { | |
country: 'France', | |
content: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment3 = await prisma.commentOptionalProp.create({ | |
data: { | |
country: 'France', | |
content: null | |
} | |
}) | |
// -1 | |
// - set should allow null | |
const comment4 = await prisma.commentOptionalProp.create({ | |
data: { | |
country: 'France', | |
content: { | |
set: null | |
} | |
} | |
}) | |
// +1 | |
const comment5 = await prisma.commentOptionalProp.create({ | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: [ | |
{ userId: '10', vote: true }, | |
] | |
} | |
} | |
} | |
}) | |
/** | |
* createMany | |
*/ | |
// +1 | |
await prisma.commentOptionalProp.createMany({ | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
await prisma.commentOptionalProp.createMany({ | |
data: { | |
country: 'France', | |
content: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
}) | |
// +1 | |
await prisma.commentOptionalProp.createMany({ | |
data: { | |
country: 'France', | |
content: null | |
} | |
}) | |
// -1 | |
// - set should allow null | |
await prisma.commentOptionalProp.createMany({ | |
data: { | |
country: 'France', | |
content: { | |
set: null | |
} | |
} | |
}) | |
// +1 | |
await prisma.commentOptionalProp.createMany({ | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: [ | |
{ userId: '10', vote: true }, | |
] | |
} | |
} | |
} | |
}) | |
/** | |
* update | |
*/ | |
// +1 | |
const comment7 = await prisma.commentOptionalProp.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment8 = await prisma.commentOptionalProp.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment9 = await prisma.commentOptionalProp.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: null | |
} | |
}) | |
// +1 | |
const comment10 = await prisma.commentOptionalProp.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
set: null | |
} | |
} | |
}) | |
// +1 | |
const comment11 = await prisma.commentOptionalProp.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: [ | |
{ userId: '10', vote: true }, | |
] | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment12 = await prisma.commentOptionalProp.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
unset: true | |
} | |
} | |
}) | |
// +1 | |
const comment13 = await prisma.commentOptionalProp.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: {}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
} | |
}) | |
// +1 (TypeScript issue) | |
const comment14 = await prisma.commentOptionalProp.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: { | |
text: "Hello World", | |
upvotes: { | |
userId: '10', | |
} | |
}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment15 = await prisma.commentOptionalProp.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: { | |
text: "Hello World", | |
upvotes: { | |
push: { | |
userId: '10', | |
vote: true, | |
} | |
} | |
}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment16 = await prisma.commentOptionalProp.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: { | |
text: "Hello World", | |
upvotes: { | |
set: { | |
userId: '10', | |
vote: true, | |
} | |
} | |
}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
} | |
}) | |
/** | |
* updateMany | |
*/ | |
// +1 | |
const comment17 = await prisma.commentOptionalProp.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment18 = await prisma.commentOptionalProp.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment19 = await prisma.commentOptionalProp.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: null | |
} | |
}) | |
// +1 | |
const comment30 = await prisma.commentOptionalProp.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
set: null | |
} | |
} | |
}) | |
// +1 | |
const comment31 = await prisma.commentOptionalProp.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: [ | |
{ userId: '10', vote: true }, | |
] | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment32 = await prisma.commentOptionalProp.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
unset: true | |
} | |
} | |
}) | |
// +1 | |
const comment33 = await prisma.commentOptionalProp.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: {}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
} | |
}) | |
// +1 (TypeScript issue) | |
const comment34 = await prisma.commentOptionalProp.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: { | |
text: "Hello World", | |
upvotes: { | |
userId: '10', | |
vote: true, | |
} | |
}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment35 = await prisma.commentOptionalProp.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: { | |
text: "Hello World", | |
upvotes: { | |
push: { | |
userId: '10', | |
vote: true, | |
} | |
} | |
}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment36 = await prisma.commentOptionalProp.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: { | |
text: "Hello World", | |
upvotes: { | |
set: { | |
userId: '10', | |
vote: true, | |
} | |
} | |
}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
} | |
}) | |
/** | |
* upsert - create | |
*/ | |
// +1 | |
const comment37 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
create: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
}, | |
update: {}, | |
}) | |
// +1 | |
const comment38 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
create: { | |
country: 'France', | |
content: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
}, | |
update: {}, | |
}) | |
// +1 | |
const comment39 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
create: { | |
country: 'France', | |
content: null | |
}, | |
update: {}, | |
}) | |
// -1 | |
// - set should allow null | |
const comment40 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
create: { | |
country: 'France', | |
content: { | |
set: null | |
} | |
}, | |
update: {}, | |
}) | |
// +1 | |
const comment41 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
create: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: [ | |
{ userId: '10', vote: true }, | |
] | |
} | |
} | |
}, | |
update: {}, | |
}) | |
/** | |
* upsert - update | |
*/ | |
// +1 | |
const comment42 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment43 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment44 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: null | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment45 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
set: null | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment46 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: [ | |
{ userId: '10', vote: true }, | |
] | |
} | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment47 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
unset: true | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment48 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: {}, | |
set: { | |
text: "Hello World", | |
}, | |
} | |
} | |
}, | |
create: {} | |
}) | |
// +1 (TypeScript issue) | |
const comment49 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: { | |
text: "Hello World", | |
upvotes: { | |
userId: '10', | |
vote: true | |
} | |
}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment50 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: { | |
text: "Hello World", | |
upvotes: { | |
push: { | |
userId: '10', | |
vote: true, | |
} | |
} | |
}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment51 = await prisma.commentOptionalProp.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: { | |
text: "Hello World", | |
upvotes: { | |
set: { | |
userId: '10', | |
vote: true, | |
} | |
} | |
}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
}, | |
create: {} | |
}) | |
/** | |
* delete | |
*/ | |
// +1 | |
await prisma.commentOptionalProp.delete({ | |
where: { | |
id: '10' | |
} | |
}) | |
/** | |
* deleteMany | |
*/ | |
// +1 | |
await prisma.commentOptionalProp.deleteMany({ | |
where: { | |
country: 'France', | |
} | |
}) | |
/** | |
* find | |
*/ | |
// +1 | |
await prisma.commentOptionalProp.findFirst({ | |
where: { | |
id: '10' | |
}, | |
select: { | |
content: { | |
select: { | |
text: true, | |
} | |
} | |
} | |
}) | |
/** | |
* findMany | |
*/ | |
// +1 | |
await prisma.commentOptionalProp.findMany({ | |
where: { | |
country: 'France', | |
// content: 42 | |
}, | |
select: { | |
content: { | |
select: { | |
text: true, | |
} | |
} | |
} | |
}) | |
prisma.$disconnect(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment