-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Doesn't meet the "no source" principle, see #1
- Loading branch information
Showing
15 changed files
with
301 additions
and
167 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package schema | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/facebook/ent" | ||
"github.com/facebook/ent/schema/edge" | ||
"github.com/facebook/ent/schema/field" | ||
) | ||
|
||
// Archive holds the schema definition for the Archive entity. | ||
type Archive struct { | ||
ent.Schema | ||
} | ||
|
||
// Fields of the Archive. | ||
func (Archive) Fields() []ent.Field { | ||
return []ent.Field{ | ||
field.Enum("status"). | ||
Values("star", "watch", "self"). | ||
Default("star"). | ||
Comment("star: a node favored by the user; watch: a node followed by the user; self: a private node created by the user."), | ||
field.Time("created_at").Default(time.Now), | ||
} | ||
} | ||
|
||
// Edges of the Archive. | ||
func (Archive) Edges() []ent.Edge { | ||
return []ent.Edge{ | ||
edge.From("user", User.Type). | ||
Ref("archives"). | ||
Unique(). | ||
Required(). | ||
Comment("The owner of the archive"), | ||
edge.From("node", Node.Type). | ||
Ref("archives"). | ||
Unique(). | ||
Required(), | ||
edge.To("assets", Asset.Type), | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package schema | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/facebook/ent" | ||
"github.com/facebook/ent/schema/edge" | ||
"github.com/facebook/ent/schema/field" | ||
) | ||
|
||
// Asset holds the schema definition for the Asset entity. | ||
type Asset struct { | ||
ent.Schema | ||
} | ||
|
||
// Fields of the Asset. | ||
func (Asset) Fields() []ent.Field { | ||
return []ent.Field{ | ||
field.Enum("status"). | ||
Values("browse", "star", "watch", "self"). | ||
Default("browse"). | ||
Comment("browse: Articles visited by users."). | ||
Comment("star: a article favored by the user."). | ||
Comment("watch: a article followed by the user."). | ||
Comment("self: a private article created by the user."), | ||
field.Time("created_at").Default(time.Now), | ||
} | ||
} | ||
|
||
// Edges of the Asset. | ||
func (Asset) Edges() []ent.Edge { | ||
return []ent.Edge{ | ||
edge.From("user", User.Type). | ||
Ref("assets"). | ||
Unique(). | ||
Required(). | ||
Comment("The owner of the asset"), | ||
edge.From("article", Article.Type). | ||
Ref("assets"). | ||
Unique(). | ||
Required(), | ||
edge.From("archives", Archive.Type). | ||
Ref("assets"), | ||
} | ||
} |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package schema | ||
|
||
import ( | ||
"github.com/facebook/ent" | ||
"github.com/facebook/ent/schema/edge" | ||
"github.com/facebook/ent/schema/field" | ||
) | ||
|
||
// Section holds the schema definition for the Section entity. | ||
type Section struct { | ||
ent.Schema | ||
} | ||
|
||
// Fields of the Section. | ||
func (Section) Fields() []ent.Field { | ||
return []ent.Field{ | ||
field.Int("index"), | ||
field.String("text"), | ||
field.Enum("type").Values("title", "text", "gist", "case").Default("text"), | ||
} | ||
} | ||
|
||
// Edges of the Section. | ||
func (Section) Edges() []ent.Edge { | ||
return []ent.Edge{ | ||
edge.To("subsections", Section.Type). | ||
Comment("subsections: the next subdivision sections of this section"). | ||
From("belong"). | ||
Comment("belong: belong to which pact"). | ||
Unique(), | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package schema | ||
|
||
import ( | ||
"github.com/facebook/ent" | ||
"github.com/facebook/ent/schema/edge" | ||
"github.com/facebook/ent/schema/field" | ||
) | ||
|
||
// Version holds the schema definition for the Version entity. | ||
type Version struct { | ||
ent.Schema | ||
} | ||
|
||
// Fields of the Version. | ||
func (Version) Fields() []ent.Field { | ||
return []ent.Field{ | ||
field.Enum("status"). | ||
Values("editing", "voting", "published"). | ||
Default("editing"). | ||
Comment("editing: The article version is in the editing state. Other users can't access and except the editor."). | ||
Comment("voting: The article version is in voting status. Except for editors and voters, no other users can access. Editors can't edit, but they can withdraw publish."). | ||
Comment("published: The article version is in the published state. If the article is public, everyone can access it, and if the article is private, only the source user can access it."), | ||
field.String("seo").Optional(), | ||
} | ||
} | ||
|
||
// Edges of the Version. | ||
func (Version) Edges() []ent.Edge { | ||
return []ent.Edge{ | ||
edge.To("content", Content.Type).Unique(), | ||
edge.From("tags", Tag.Type).Ref("versions"), | ||
edge.From("article", Article.Type).Ref("versions").Unique().Required(), | ||
edge.To("lang", Language.Type).Unique().Required(), | ||
} | ||
} |
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
Oops, something went wrong.