summaryrefslogtreecommitdiffstats
path: root/backend/database
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-01-30 12:41:01 -0500
committerWes Bos <wesbos@gmail.com>2018-01-30 12:41:01 -0500
commitcd0b07b3adb36fb5ec098f9e511ab45d774fee7b (patch)
treea203e5010219ccea1acc6bbd2c0a4bcfa0a78615 /backend/database
parent0a1648bf47490b312169c531aeb51ef4725e8d2e (diff)
Move to Prisma Backend
Diffstat (limited to 'backend/database')
-rw-r--r--backend/database/datamodel.graphql26
-rw-r--r--backend/database/prisma.yml21
-rw-r--r--backend/database/seed.graphql24
3 files changed, 71 insertions, 0 deletions
diff --git a/backend/database/datamodel.graphql b/backend/database/datamodel.graphql
new file mode 100644
index 0000000..605e242
--- /dev/null
+++ b/backend/database/datamodel.graphql
@@ -0,0 +1,26 @@
+type Post {
+ id: ID! @unique
+ createdAt: DateTime!
+ updatedAt: DateTime!
+ isPublished: Boolean! @default(value: "false")
+ title: String!
+ text: String!
+ author: User!
+}
+
+type User {
+ id: ID! @unique
+ email: String! @unique
+ password: String!
+ name: String!
+ posts: [Post!]!
+ website: String
+ age: Int
+}
+
+type Item {
+ id: ID! @unique
+ title: String!
+ description: String!
+ price: Int!
+}
diff --git a/backend/database/prisma.yml b/backend/database/prisma.yml
new file mode 100644
index 0000000..6570be2
--- /dev/null
+++ b/backend/database/prisma.yml
@@ -0,0 +1,21 @@
+# the name for the service (will be part of the service's HTTP endpoint)
+service: my-own
+
+# the cluster and stage the service is deployed to
+stage: ${env:PRISMA_STAGE}
+
+# to disable authentication:
+# disableAuth: true
+secret: ${env:PRISMA_SECRET}
+
+# the file path pointing to your data model
+datamodel: datamodel.graphql
+
+# uncomment the following two lines to seed your service with initial data
+# seed:
+# import: seed.graphql
+
+cluster: ${env:PRISMA_CLUSTER}
+
+
+disableAuth: true \ No newline at end of file
diff --git a/backend/database/seed.graphql b/backend/database/seed.graphql
new file mode 100644
index 0000000..5779328
--- /dev/null
+++ b/backend/database/seed.graphql
@@ -0,0 +1,24 @@
+mutation {
+ createUser(data: {
+ email: "developer@example.com"
+ password: "$2a$10$hACwQ5/HQI6FhbIISOUVeusy3sKyUDhSq36fF5d/54aAdiygJPFzm" # plaintext password: "nooneknows"
+ name: "Sarah"
+ posts: {
+ create: [{
+ title: "Hello World"
+ text: "This is my first blog post ever!"
+ isPublished: true
+ }, {
+ title: "My Second Post"
+ text: "My first post was good, but this one is better!"
+ isPublished: true
+ }, {
+ title: "Solving World Hunger"
+ text: "This is a draft..."
+ isPublished: false
+ }]
+ }
+ }) {
+ id
+ }
+} \ No newline at end of file