mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-03 17:18:36 +00:00
fix: csv-importer (#10)
* update item fields to support import_ref * add additional rows to CSV importer * add CSV import documentation * update readme * update readme * fix failed test
This commit is contained in:
parent
90813abf76
commit
ca36e3b080
21 changed files with 447 additions and 135 deletions
|
@ -34,6 +34,10 @@ func (Item) Indexes() []ent.Index {
|
|||
// Fields of the Item.
|
||||
func (Item) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("import_ref").
|
||||
Optional().
|
||||
MaxLen(100).
|
||||
Immutable(),
|
||||
field.String("notes").
|
||||
MaxLen(1000).
|
||||
Optional(),
|
||||
|
@ -102,7 +106,10 @@ func (Item) Edges() []ent.Edge {
|
|||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.From("label", Label.Type).
|
||||
Ref("items"),
|
||||
Ref("items").
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.To("attachments", Attachment.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
|
|
|
@ -2,6 +2,7 @@ package schema
|
|||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/hay-kot/content/backend/ent/schema/mixins"
|
||||
|
@ -35,6 +36,9 @@ func (Label) Edges() []ent.Edge {
|
|||
Ref("labels").
|
||||
Required().
|
||||
Unique(),
|
||||
edge.To("items", Item.Type),
|
||||
edge.To("items", Item.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package schema
|
|||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"github.com/hay-kot/content/backend/ent/schema/mixins"
|
||||
)
|
||||
|
@ -30,6 +31,9 @@ func (Location) Edges() []ent.Edge {
|
|||
Ref("locations").
|
||||
Unique().
|
||||
Required(),
|
||||
edge.To("items", Item.Type),
|
||||
edge.To("items", Item.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue