Browse Source

schema update

Ivan Asmer 5 years ago
parent
commit
3e4f34728a
2 changed files with 49 additions and 86 deletions
  1. 45 86
      index.js
  2. 4 0
      models.js

+ 45 - 86
index.js

@@ -24,11 +24,6 @@ const upload  = require('multer')({ dest: uploadPath })
              login: String
              nick : String
              avatar: Image
-             likes: [Like]
-             likesCount: Int
-             incomings: [Direct]
-             followers: [User]
-             following: [User]
         }
 
         input UserInput {
@@ -36,47 +31,6 @@ const upload  = require('multer')({ dest: uploadPath })
              login: String
              nick : String
              avatar: ImageInput
-             following: [UserInput]
-        }
-
-        type Like {
-            _id: ID,
-            post: Post,
-            comment: Comment,
-            direct: Direct,
-            owner: User
-        }
-
-        input LikeInput {
-            _id: ID,
-            post: PostInput,
-            comment: CommentInput,
-            direct: DirectInput,
-            user: UserInput,
-        }
-
-        type Post {
-            _id: ID,
-            createdAt: String
-            title: String
-            text: String,
-            images: [Image],
-            comments: [Comment],
-            directs: [Direct],
-            collections: [Collection]
-            likes: [Like]
-            likesCount: Int
-            owner: User
-        }
-
-        input PostInput {
-            _id: ID,
-            title: String,
-            text: String,
-            images: [ImageInput],
-            comments: [CommentInput],
-            directs: [DirectInput],
-            collections: [CollectionInput]
         }
 
         type Image {
@@ -85,8 +39,8 @@ const upload  = require('multer')({ dest: uploadPath })
             url: String,
             originalFileName: String,
             userAvatar: User,
-            posts: [Post],
-            directs: [Direct]
+            good: Good
+            category: Category
             owner: User
         }
 
@@ -94,62 +48,67 @@ const upload  = require('multer')({ dest: uploadPath })
             _id: ID,
             text: String,
             userAvatar: UserInput,
-            posts: [PostInput],
-            directs: [DirectInput]
+            good: GoodInput
+            category: CategoryInput
         }
 
-        type Comment {
+        type Category {
             _id: ID,
-            createdAt: String,
-            text: String,
-            post: Post,
-            answers: [Comment],
-            answerTo: Comment
-            likes: [Like]
-            likesCount: Int
-            owner: User
+            name: String!,
+            goods: [Good]
+            image: Image
         }
 
-        input CommentInput {
+        input CategoryInput {
             _id: ID,
-            text: String,
-            post: PostInput,
-            answers: [CommentInput],
-            answerTo: CommentInput
+            name: String!,
+            goods: [ID]
+            image: ImageInput
         }
 
-        type Direct {
+        type Good {
             _id: ID,
-            createdAt: String,
-            text: String,
-            post: Post,
-            image: Image,
-            likes: [Like]
-            likesCount: Int
-            to: User
-            owner: User
+            name: String!,
+            description: String
+            price: Float
+            orderGoods: [OrderGood]
+            categories: [Category]
+            images: [Image]
         }
 
-        input DirectInput {
+        input GoodInput {
             _id: ID,
-            text: String,
-            post: PostInput,
-            image: ImageInput,
-            likes: [LikeInput]
-            to: UserInput
+            name: String!,
+            description: String
+            price: Float
+            categories: [CategoryInput]
+            images: [ImageInput]
         }
 
-        type Collection {
+        type OrderGood {
             _id: ID,
-            text: String,
-            posts: [Post]
-            owner: User
+            price: Float,
+            count: Float,
+            good: Good,
+            order: Order
         }
 
-        input CollectionInput {
+        input OrderGoodInput {
             _id: ID,
-            text: String,
-            posts: [PostInput]
+            count: Int!,
+            good: [GoodInput],
+            order: [OrderInput]
+        }
+
+        type Order {
+            _id: ID
+            total: Float
+            orderGoods: [OrderGood]
+        }
+
+        input OrderInput {
+            _id: ID
+            orderGoods: [OrderGoodInput]
         }
     `);
 

+ 4 - 0
models.js

@@ -63,6 +63,8 @@ module.exports = async (dbName='shop') => {
             static get relations(){
                 return {
                     userAvatar: "avatar", //if it is ava
+                    good: ["images"], //if it is ava
+                    category: "image", //if it is ava
                 }
             }
 
@@ -78,6 +80,7 @@ module.exports = async (dbName='shop') => {
                 return {
                     categories: ["goods"],
                     orderGoods: "good",
+                    images: "good"
                 }
             }
         }
@@ -91,6 +94,7 @@ module.exports = async (dbName='shop') => {
             static get relations(){
                 return {
                     goods: ["categories"],
+                    image: "category",
                 }
             }
         }