Last active
February 17, 2022 10:30
-
-
Save millsp/b0961ec696754bcda4df4641c7b1adb6 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"; | |
(async () => { | |
const prisma = new PrismaClient(); | |
await prisma.user.create({ | |
data: { | |
email: Date.now() + "", | |
}, | |
}); | |
/** | |
* create | |
*/ | |
// +1 | |
const comment1 = await prisma.comment.create({ | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment2 = await prisma.comment.create({ | |
data: { | |
country: 'France', | |
content: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment3 = await prisma.comment.create({ | |
data: { | |
country: 'France', | |
content: null | |
} | |
}) | |
// +1 | |
const comment4 = await prisma.comment.create({ | |
data: { | |
country: 'France', | |
content: { | |
set: null | |
} | |
} | |
}) | |
// +1 | |
const comment5 = await prisma.comment.create({ | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: [ | |
{ userId: '10', vote: true }, | |
] | |
} | |
} | |
} | |
}) | |
/** | |
* createMany | |
*/ | |
// -1 | |
// - only `id` is available | |
// - relevant piece of DMMF | |
// { | |
// "name": "CommentCreateManyInput", | |
// "constraints": { | |
// "maxNumFields": null, | |
// "minNumFields": null | |
// }, | |
// "fields": [ | |
// { | |
// "name": "id", | |
// "isRequired": false, | |
// "isNullable": false, | |
// "inputTypes": [ | |
// { | |
// "type": "String", | |
// "location": "scalar", | |
// "isList": false | |
// } | |
// ] | |
// } | |
// ] | |
// } | |
const comment6 = await prisma.comment.createMany({ | |
data: [ | |
{ | |
country: 'France', | |
content: {}, // `content` not available | |
} | |
] | |
}) | |
/** | |
* update | |
*/ | |
// +1 | |
const comment7 = await prisma.comment.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment8 = await prisma.comment.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment9 = await prisma.comment.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: null | |
} | |
}) | |
// -1 | |
// - Cannot set `content` to `null` | |
// - relevant piece of DMMF | |
// "name": "CommentContentNullableUpdateEnvelopeInput", | |
// "fields": [ | |
// { | |
// "name": "set", | |
// "isRequired": false, | |
// "isNullable": false, | |
// "inputTypes": [ | |
// { | |
// "type": "CommentContentCreateInput", | |
// "namespace": "prisma", | |
// "location": "inputObjectTypes", | |
// "isList": false | |
// } | |
// ] | |
// }, | |
const comment10 = await prisma.comment.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
set: null | |
} | |
} | |
}) | |
// +1 | |
const comment11 = await prisma.comment.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: [ | |
{ userId: '10', vote: true }, | |
] | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment12 = await prisma.comment.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
unset: true | |
} | |
} | |
}) | |
// +1 | |
const comment13 = await prisma.comment.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: {}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
} | |
}) | |
// -1 (TypeScript issue) | |
// - Looks like our XOR types are not working | |
const comment14 = await prisma.comment.update({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: { | |
text: "Hello World", | |
upvotes: { | |
userId: '10', | |
// is this valid without `vote`? | |
} | |
}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment15 = await prisma.comment.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.comment.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.comment.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment18 = await prisma.comment.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment19 = await prisma.comment.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: null | |
} | |
}) | |
// -1 | |
// - Cannot set `content` to `null` | |
// - relevant piece of DMMF | |
// "name": "CommentContentNullableUpdateEnvelopeInput", | |
// "fields": [ | |
// { | |
// "name": "set", | |
// "isRequired": false, | |
// "isNullable": false, | |
// "inputTypes": [ | |
// { | |
// "type": "CommentContentCreateInput", | |
// "namespace": "prisma", | |
// "location": "inputObjectTypes", | |
// "isList": false | |
// } | |
// ] | |
// }, | |
const comment30 = await prisma.comment.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
set: null | |
} | |
} | |
}) | |
// +1 | |
const comment31 = await prisma.comment.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: [ | |
{ userId: '10', vote: true }, | |
] | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment32 = await prisma.comment.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
unset: true | |
} | |
} | |
}) | |
// +1 | |
const comment33 = await prisma.comment.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: {}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
} | |
}) | |
// -1 (TypeScript issue) | |
// - Looks like our XOR types are not working | |
const comment34 = await prisma.comment.updateMany({ | |
where: { | |
id: '10' | |
}, | |
data: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: { | |
text: "Hello World", | |
upvotes: { | |
userId: '10', | |
// is this valid without `vote`? | |
} | |
}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
} | |
}) | |
// +1 | |
const comment35 = await prisma.comment.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.comment.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.comment.upsert({ | |
where: { | |
id: '10' | |
}, | |
create: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
}, | |
update: {}, | |
}) | |
// +1 | |
const comment38 = await prisma.comment.upsert({ | |
where: { | |
id: '10' | |
}, | |
create: { | |
country: 'France', | |
content: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
}, | |
update: {}, | |
}) | |
// +1 | |
const comment39 = await prisma.comment.upsert({ | |
where: { | |
id: '10' | |
}, | |
create: { | |
country: 'France', | |
content: null | |
}, | |
update: {}, | |
}) | |
// +1 | |
const comment40 = await prisma.comment.upsert({ | |
where: { | |
id: '10' | |
}, | |
create: { | |
country: 'France', | |
content: { | |
set: null | |
} | |
}, | |
update: {}, | |
}) | |
// +1 | |
const comment41 = await prisma.comment.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.comment.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment43 = await prisma.comment.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
text: "Hello World", | |
upvotes: { | |
vote: true, | |
userId: '10' | |
} | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment44 = await prisma.comment.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: null | |
}, | |
create: {} | |
}) | |
// -1 | |
// - Cannot set `content` to `null` | |
// - relevant piece of DMMF | |
// "name": "CommentContentNullableUpdateEnvelopeInput", | |
// "fields": [ | |
// { | |
// "name": "set", | |
// "isRequired": false, | |
// "isNullable": false, | |
// "inputTypes": [ | |
// { | |
// "type": "CommentContentCreateInput", | |
// "namespace": "prisma", | |
// "location": "inputObjectTypes", | |
// "isList": false | |
// } | |
// ] | |
// }, | |
const comment45 = await prisma.comment.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
set: null | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment46 = await prisma.comment.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
set: { | |
text: "Hello World", | |
upvotes: [ | |
{ userId: '10', vote: true }, | |
] | |
} | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment47 = await prisma.comment.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
unset: true | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment48 = await prisma.comment.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: {}, | |
set: { | |
text: "Hello World", | |
}, | |
} | |
} | |
}, | |
create: {} | |
}) | |
// -1 (TypeScript issue) | |
// - Looks like our XOR types are not working | |
const comment49 = await prisma.comment.upsert({ | |
where: { | |
id: '10' | |
}, | |
update: { | |
country: 'France', | |
content: { | |
upsert: { | |
update: { | |
text: "Hello World", | |
upvotes: { | |
userId: '10', | |
// is this valid without `vote`? | |
} | |
}, | |
set: { | |
text: "Hello World", | |
} | |
} | |
} | |
}, | |
create: {} | |
}) | |
// +1 | |
const comment50 = await prisma.comment.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.comment.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.comment.delete({ | |
where: { | |
id: '10' | |
} | |
}) | |
/** | |
* deleteMany | |
*/ | |
// -1 | |
// - `content` is not available yet | |
// - `content` is shown as a number | |
// - relevant piece of DMMF | |
// | |
// "name": "CommentWhereInput", | |
// "constraints": { | |
// "maxNumFields": null, | |
// "minNumFields": null | |
// }, | |
// "fields": [ | |
// { | |
// "name": "content", | |
// "isRequired": false, | |
// "isNullable": false, | |
// "inputTypes": [ | |
// { | |
// "type": "Int", | |
// "location": "scalar", | |
// "isList": false | |
// } | |
// ] | |
// }, | |
await prisma.comment.deleteMany({ | |
where: { | |
country: 'France', | |
content: 42 | |
} | |
}) | |
/** | |
* find | |
*/ | |
// +1 | |
await prisma.comment.delete({ | |
where: { | |
id: '10' | |
} | |
}) | |
/** | |
* findMany | |
*/ | |
// -1 | |
// - `content` is not available yet | |
// - `content` is shown as a number | |
// - relevant piece of DMMF | |
// | |
// "name": "CommentWhereInput", | |
// "constraints": { | |
// "maxNumFields": null, | |
// "minNumFields": null | |
// }, | |
// "fields": [ | |
// { | |
// "name": "content", | |
// "isRequired": false, | |
// "isNullable": false, | |
// "inputTypes": [ | |
// { | |
// "type": "Int", | |
// "location": "scalar", | |
// "isList": false | |
// } | |
// ] | |
// }, | |
await prisma.comment.findMany({ | |
where: { | |
country: 'France', | |
content: 42 | |
} | |
}) | |
prisma.$disconnect(); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment