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:
Hayden 2022-09-12 20:54:30 -08:00 committed by GitHub
parent 90813abf76
commit ca36e3b080
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 447 additions and 135 deletions

View file

@ -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,

View file

@ -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,
}),
}
}

View file

@ -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,
}),
}
}