mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
improved schema
This commit is contained in:
parent
2105b4d4aa
commit
81216f52c6
@ -15,6 +15,10 @@ type WrittenPost @relation(name: "WROTE") {
|
||||
to: Post
|
||||
timestamp: Int # TODO: change that to custom Date Type
|
||||
}
|
||||
# type WrittenPost2 {
|
||||
# Post: Post!
|
||||
# timestamp: Int # TODO: change that to custom Date Type
|
||||
# }
|
||||
type WrittenComment @relation(name: "WROTE") {
|
||||
from: User
|
||||
to: Comment
|
||||
@ -23,30 +27,41 @@ type WrittenComment @relation(name: "WROTE") {
|
||||
|
||||
type User {
|
||||
id: ID!
|
||||
name: String!
|
||||
name: String @default(to: "Anonymus")
|
||||
email: String
|
||||
slug: String
|
||||
password: String!
|
||||
avatar: String
|
||||
deleted: Boolean @default(to: false)
|
||||
disabled: Boolean @default(to: false)
|
||||
role: UserGroupEnum
|
||||
|
||||
friends: [User]! @relation(name: "FRIENDS", direction: "BOTH")
|
||||
friendsCount: Int! @cypher(statement: "MATCH (this)<-[:FRIENDS]->(r:User) RETURN COUNT(r)")
|
||||
|
||||
following: [User]! @relation(name: "FOLLOWING", direction: "OUT")
|
||||
followingCount: Int! @cypher(statement: "MATCH (this)-[:FOLLOWING]->(r:User) RETURN COUNT(r)")
|
||||
following: [User]! @relation(name: "FOLLOWS", direction: "OUT")
|
||||
followingCount: Int! @cypher(statement: "MATCH (this)-[:FOLLOWS]->(r:User) RETURN COUNT(r)")
|
||||
|
||||
followedBy: [User]! @relation(name: "FOLLOWING", direction: "IN")
|
||||
followedByCount: Int! @cypher(statement: "MATCH (this)<-[:FOLLOWING]-(r:User) RETURN COUNT(r)")
|
||||
followedBy: [User]! @relation(name: "FOLLOWS", direction: "IN")
|
||||
followedByCount: Int! @cypher(statement: "MATCH (this)<-[:FOLLOWS]-(r:User) RETURN COUNT(r)")
|
||||
|
||||
contributions: [WrittenPost]!
|
||||
contributionsCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(r:Post) RETURN COUNT(r)")
|
||||
#contributions2(first: Int = 10, offset: Int = 0): [WrittenPost2]!
|
||||
# @cypher(
|
||||
# statement: "MATCH (this)-[w:WROTE]->(p:Post) RETURN p as Post, w.timestamp as timestamp"
|
||||
# )
|
||||
contributionsCount: Int! @cypher(statement: """
|
||||
MATCH (this)-[:WROTE]->(r:Post)
|
||||
WHERE (NOT exists(r.deleted) OR r.deleted = false)
|
||||
AND (NOT exists(r.disabled) OR r.disabled = false)
|
||||
RETURN COUNT(r)"""
|
||||
)
|
||||
|
||||
comments: [WrittenComment]!
|
||||
commentsCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(r:Comment) RETURN COUNT(r)")
|
||||
|
||||
shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT")
|
||||
shoutedCount: Int! @cypher(statement: "MATCH (this)-[:SHOUTED]->(r:Post) RETURN COUNT(r)")
|
||||
|
||||
organizationsCreated: [Organization] @relation(name: "CREATED_ORGA", direction: "OUT")
|
||||
organizationsOwned: [Organization] @relation(name: "OWNING_ORGA", direction: "OUT")
|
||||
@ -66,16 +81,19 @@ type Post {
|
||||
contentExcerpt: String
|
||||
image: String
|
||||
visibility: VisibilityEnum
|
||||
disabled: Boolean @default(to: false)
|
||||
deleted: Boolean @default(to: false)
|
||||
|
||||
# relatedContributions: [Post]! @cypher(statement: "MATCH (this)-[:TAGGED]->(t:Tag)<-[:TAGGED]-(p1:Post) MATCH (this)-[:CATEGORIZED]->(t:Category)<-[:CATEGORIZED]-(p2:Post) RETURN collect(distinct p2) + p1")
|
||||
relatedContributions: [Post]! @cypher(statement: "MATCH (this)-[:TAGGED]->(t:Tag)<-[:TAGGED]-(p:Post) return p")
|
||||
relatedContributions: [Post]! @cypher(statement: """
|
||||
MATCH (this)-[:TAGGED|CATEGORIZED]->(categoryOrTag)<-[:TAGGED|CATEGORIZED]-(post:Post)
|
||||
RETURN DISTINCT post
|
||||
LIMIT 10
|
||||
""")
|
||||
|
||||
tags: [Tag]! @relation(name: "TAGGED", direction: "OUT")
|
||||
categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT")
|
||||
|
||||
comments: [Comment]! @relation(name: "COMMENT", direction: "IN")
|
||||
commentsCount: Int! @cypher(statement: "MATCH (this)<-[:COMMENT]-(r:Comment) RETURN COUNT(r)")
|
||||
comments: [Comment]! @relation(name: "COMMENTS", direction: "IN")
|
||||
commentsCount: Int! @cypher(statement: "MATCH (this)<-[:COMMENTS]-(r:Comment) RETURN COUNT(r)")
|
||||
|
||||
shoutedBy: [User]! @relation(name: "SHOUTED", direction: "IN")
|
||||
shoutedCount: Int! @cypher(statement: "MATCH (this)<-[:SHOUTED]-(r:User) RETURN COUNT(r)")
|
||||
@ -87,7 +105,7 @@ type Comment {
|
||||
content: String!
|
||||
contentExcerpt: String
|
||||
post: Post @relation(name: "COMMENT", direction: "OUT")
|
||||
disabled: Boolean @default(to: false)
|
||||
deleted: Boolean @default(to: false)
|
||||
}
|
||||
|
||||
type Category {
|
||||
@ -95,6 +113,8 @@ type Category {
|
||||
name: String!
|
||||
slug: String
|
||||
icon: String!
|
||||
posts: [Post]! @relation(name: "CATEGORIZED", direction: "IN")
|
||||
postCount: Int! @cypher(statement: "MATCH (this)<-[:CATEGORIZED]-(r:Post) RETURN COUNT(r)")
|
||||
}
|
||||
|
||||
type Badge {
|
||||
@ -124,7 +144,7 @@ type Organization {
|
||||
slug: String
|
||||
description: String!
|
||||
descriptionExcerpt: String
|
||||
disabled: Boolean @default(to: false)
|
||||
deleted: Boolean @default(to: false)
|
||||
|
||||
tags: [Tag]! @relation(name: "TAGGED", direction: "OUT")
|
||||
categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT")
|
||||
@ -136,5 +156,5 @@ type Tag {
|
||||
taggedPosts: [Post]! @relation(name: "TAGGED", direction: "IN")
|
||||
taggedOrganizations: [Organization]! @relation(name: "TAGGED", direction: "IN")
|
||||
taggedCount: Int! @cypher(statement: "MATCH (this)<-[:TAGGED]-(r) RETURN COUNT(r)")
|
||||
disabled: Boolean @default(to: false)
|
||||
deleted: Boolean @default(to: false)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user