Example models 1.

parent 04d16679
No preview for this file type
......@@ -5,14 +5,29 @@ import { text, relationship } from '@keystone-6/core/fields';
import { ServerConfig } from '@keystone-6/core/types';
const lists = {
Role: list({
access: allowAll,
fields: {
name: text({ validation: { isRequired: true } }),
users: relationship({ ref: 'User.role', many: false }),
},
}),
User: list({
access: allowAll,
fields: {
name: text({ validation: { isRequired: true } }),
email: text({ validation: { isRequired: true }, isIndexed: 'unique' }),
role: relationship({
ref: 'Role.users',
}),
posts: relationship({ ref: 'Post.author', many: true }),
},
}),
Post: list({
access: allowAll,
fields: {
......@@ -29,6 +44,21 @@ const lists = {
}),
},
}),
Tariff: list({
access: allowAll,
fields: {
name: text({ validation: { isRequired: true } })
},
}),
Account: list({
access: allowAll,
fields: {
name: text({ validation: { isRequired: true } })
},
}),
};
export default config({
......
......@@ -4,6 +4,13 @@
"description": "Example fog gc.",
"main": "index.js",
"license": "MIT",
"scripts": {
"dev": "PORT=9000 keystone dev",
"start": "PORT=9000 keystone start",
"build": "PORT=9000 keystone build",
"postinstall": "PORT=9000 keystone postinstall",
"seed-data": "PORT=9000 tsx seed-data.ts"
},
"dependencies": {
"@keystone-6/core": "^5.7.0",
"typescript": "^5.2.2"
......
# This file is automatically generated by Keystone, do not modify it manually.
# Modify your Keystone config when you want to change this.
type User {
type Role {
id: ID!
name: String
email: String
posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!]
postsCount(where: PostWhereInput! = {}): Int
users: User
}
input UserWhereUniqueInput {
input RoleWhereUniqueInput {
id: ID
email: String
}
input UserWhereInput {
AND: [UserWhereInput!]
OR: [UserWhereInput!]
NOT: [UserWhereInput!]
input RoleWhereInput {
AND: [RoleWhereInput!]
OR: [RoleWhereInput!]
NOT: [RoleWhereInput!]
id: IDFilter
name: StringFilter
email: StringFilter
posts: PostManyRelationFilter
users: UserWhereInput
}
input IDFilter {
......@@ -63,6 +59,67 @@ input NestedStringFilter {
not: NestedStringFilter
}
input RoleOrderByInput {
id: OrderDirection
name: OrderDirection
}
enum OrderDirection {
asc
desc
}
input RoleUpdateInput {
name: String
users: UserRelateToOneForUpdateInput
}
input UserRelateToOneForUpdateInput {
create: UserCreateInput
connect: UserWhereUniqueInput
disconnect: Boolean
}
input RoleUpdateArgs {
where: RoleWhereUniqueInput!
data: RoleUpdateInput!
}
input RoleCreateInput {
name: String
users: UserRelateToOneForCreateInput
}
input UserRelateToOneForCreateInput {
create: UserCreateInput
connect: UserWhereUniqueInput
}
type User {
id: ID!
name: String
email: String
role: Role
posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!]
postsCount(where: PostWhereInput! = {}): Int
}
input UserWhereUniqueInput {
id: ID
email: String
}
input UserWhereInput {
AND: [UserWhereInput!]
OR: [UserWhereInput!]
NOT: [UserWhereInput!]
id: IDFilter
name: StringFilter
email: StringFilter
role: RoleWhereInput
posts: PostManyRelationFilter
}
input PostManyRelationFilter {
every: PostWhereInput
some: PostWhereInput
......@@ -75,17 +132,19 @@ input UserOrderByInput {
email: OrderDirection
}
enum OrderDirection {
asc
desc
}
input UserUpdateInput {
name: String
email: String
role: RoleRelateToOneForUpdateInput
posts: PostRelateToManyForUpdateInput
}
input RoleRelateToOneForUpdateInput {
create: RoleCreateInput
connect: RoleWhereUniqueInput
disconnect: Boolean
}
input PostRelateToManyForUpdateInput {
disconnect: [PostWhereUniqueInput!]
set: [PostWhereUniqueInput!]
......@@ -101,9 +160,15 @@ input UserUpdateArgs {
input UserCreateInput {
name: String
email: String
role: RoleRelateToOneForCreateInput
posts: PostRelateToManyForCreateInput
}
input RoleRelateToOneForCreateInput {
create: RoleCreateInput
connect: RoleWhereUniqueInput
}
input PostRelateToManyForCreateInput {
create: [PostCreateInput!]
connect: [PostWhereUniqueInput!]
......@@ -138,12 +203,6 @@ input PostUpdateInput {
author: UserRelateToOneForUpdateInput
}
input UserRelateToOneForUpdateInput {
create: UserCreateInput
connect: UserWhereUniqueInput
disconnect: Boolean
}
input PostUpdateArgs {
where: PostWhereUniqueInput!
data: PostUpdateInput!
......@@ -154,9 +213,74 @@ input PostCreateInput {
author: UserRelateToOneForCreateInput
}
input UserRelateToOneForCreateInput {
create: UserCreateInput
connect: UserWhereUniqueInput
type Tariff {
id: ID!
name: String
}
input TariffWhereUniqueInput {
id: ID
}
input TariffWhereInput {
AND: [TariffWhereInput!]
OR: [TariffWhereInput!]
NOT: [TariffWhereInput!]
id: IDFilter
name: StringFilter
}
input TariffOrderByInput {
id: OrderDirection
name: OrderDirection
}
input TariffUpdateInput {
name: String
}
input TariffUpdateArgs {
where: TariffWhereUniqueInput!
data: TariffUpdateInput!
}
input TariffCreateInput {
name: String
}
type Account {
id: ID!
name: String
}
input AccountWhereUniqueInput {
id: ID
}
input AccountWhereInput {
AND: [AccountWhereInput!]
OR: [AccountWhereInput!]
NOT: [AccountWhereInput!]
id: IDFilter
name: StringFilter
}
input AccountOrderByInput {
id: OrderDirection
name: OrderDirection
}
input AccountUpdateInput {
name: String
}
input AccountUpdateArgs {
where: AccountWhereUniqueInput!
data: AccountUpdateInput!
}
input AccountCreateInput {
name: String
}
"""
......@@ -165,6 +289,12 @@ The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://
scalar JSON @specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")
type Mutation {
createRole(data: RoleCreateInput!): Role
createRoles(data: [RoleCreateInput!]!): [Role]
updateRole(where: RoleWhereUniqueInput!, data: RoleUpdateInput!): Role
updateRoles(data: [RoleUpdateArgs!]!): [Role]
deleteRole(where: RoleWhereUniqueInput!): Role
deleteRoles(where: [RoleWhereUniqueInput!]!): [Role]
createUser(data: UserCreateInput!): User
createUsers(data: [UserCreateInput!]!): [User]
updateUser(where: UserWhereUniqueInput!, data: UserUpdateInput!): User
......@@ -177,15 +307,36 @@ type Mutation {
updatePosts(data: [PostUpdateArgs!]!): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
createTariff(data: TariffCreateInput!): Tariff
createTariffs(data: [TariffCreateInput!]!): [Tariff]
updateTariff(where: TariffWhereUniqueInput!, data: TariffUpdateInput!): Tariff
updateTariffs(data: [TariffUpdateArgs!]!): [Tariff]
deleteTariff(where: TariffWhereUniqueInput!): Tariff
deleteTariffs(where: [TariffWhereUniqueInput!]!): [Tariff]
createAccount(data: AccountCreateInput!): Account
createAccounts(data: [AccountCreateInput!]!): [Account]
updateAccount(where: AccountWhereUniqueInput!, data: AccountUpdateInput!): Account
updateAccounts(data: [AccountUpdateArgs!]!): [Account]
deleteAccount(where: AccountWhereUniqueInput!): Account
deleteAccounts(where: [AccountWhereUniqueInput!]!): [Account]
}
type Query {
roles(where: RoleWhereInput! = {}, orderBy: [RoleOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: RoleWhereUniqueInput): [Role!]
role(where: RoleWhereUniqueInput!): Role
rolesCount(where: RoleWhereInput! = {}): Int
users(where: UserWhereInput! = {}, orderBy: [UserOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: UserWhereUniqueInput): [User!]
user(where: UserWhereUniqueInput!): User
usersCount(where: UserWhereInput! = {}): Int
posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!]
post(where: PostWhereUniqueInput!): Post
postsCount(where: PostWhereInput! = {}): Int
tariffs(where: TariffWhereInput! = {}, orderBy: [TariffOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: TariffWhereUniqueInput): [Tariff!]
tariff(where: TariffWhereUniqueInput!): Tariff
tariffsCount(where: TariffWhereInput! = {}): Int
accounts(where: AccountWhereInput! = {}, orderBy: [AccountOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: AccountWhereUniqueInput): [Account!]
account(where: AccountWhereUniqueInput!): Account
accountsCount(where: AccountWhereInput! = {}): Int
keystone: KeystoneMeta!
}
......
......@@ -11,10 +11,18 @@ generator client {
provider = "prisma-client-js"
}
model Role {
id String @id @default(cuid())
name String @default("")
users User? @relation("Role_users", fields: [usersId], references: [id])
usersId String? @unique @map("users")
}
model User {
id String @id @default(cuid())
name String @default("")
email String @unique @default("")
role Role? @relation("Role_users")
posts Post[] @relation("Post_author")
}
......@@ -26,3 +34,13 @@ model Post {
@@index([authorId])
}
model Tariff {
id String @id @default(cuid())
name String @default("")
}
model Account {
id String @id @default(cuid())
name String @default("")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment