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

@ -21,6 +21,8 @@ const (
FieldName = "name"
// FieldDescription holds the string denoting the description field in the database.
FieldDescription = "description"
// FieldImportRef holds the string denoting the import_ref field in the database.
FieldImportRef = "import_ref"
// FieldNotes holds the string denoting the notes field in the database.
FieldNotes = "notes"
// FieldQuantity holds the string denoting the quantity field in the database.
@ -107,6 +109,7 @@ var Columns = []string{
FieldUpdatedAt,
FieldName,
FieldDescription,
FieldImportRef,
FieldNotes,
FieldQuantity,
FieldInsured,
@ -164,6 +167,8 @@ var (
NameValidator func(string) error
// DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
DescriptionValidator func(string) error
// ImportRefValidator is a validator for the "import_ref" field. It is called by the builders before save.
ImportRefValidator func(string) error
// NotesValidator is a validator for the "notes" field. It is called by the builders before save.
NotesValidator func(string) error
// DefaultQuantity holds the default value on creation for the "quantity" field.

View file

@ -110,6 +110,13 @@ func Description(v string) predicate.Item {
})
}
// ImportRef applies equality check predicate on the "import_ref" field. It's identical to ImportRefEQ.
func ImportRef(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldImportRef), v))
})
}
// Notes applies equality check predicate on the "notes" field. It's identical to NotesEQ.
func Notes(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
@ -562,6 +569,119 @@ func DescriptionContainsFold(v string) predicate.Item {
})
}
// ImportRefEQ applies the EQ predicate on the "import_ref" field.
func ImportRefEQ(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldImportRef), v))
})
}
// ImportRefNEQ applies the NEQ predicate on the "import_ref" field.
func ImportRefNEQ(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldImportRef), v))
})
}
// ImportRefIn applies the In predicate on the "import_ref" field.
func ImportRefIn(vs ...string) predicate.Item {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldImportRef), v...))
})
}
// ImportRefNotIn applies the NotIn predicate on the "import_ref" field.
func ImportRefNotIn(vs ...string) predicate.Item {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldImportRef), v...))
})
}
// ImportRefGT applies the GT predicate on the "import_ref" field.
func ImportRefGT(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldImportRef), v))
})
}
// ImportRefGTE applies the GTE predicate on the "import_ref" field.
func ImportRefGTE(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldImportRef), v))
})
}
// ImportRefLT applies the LT predicate on the "import_ref" field.
func ImportRefLT(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldImportRef), v))
})
}
// ImportRefLTE applies the LTE predicate on the "import_ref" field.
func ImportRefLTE(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldImportRef), v))
})
}
// ImportRefContains applies the Contains predicate on the "import_ref" field.
func ImportRefContains(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.Contains(s.C(FieldImportRef), v))
})
}
// ImportRefHasPrefix applies the HasPrefix predicate on the "import_ref" field.
func ImportRefHasPrefix(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.HasPrefix(s.C(FieldImportRef), v))
})
}
// ImportRefHasSuffix applies the HasSuffix predicate on the "import_ref" field.
func ImportRefHasSuffix(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.HasSuffix(s.C(FieldImportRef), v))
})
}
// ImportRefIsNil applies the IsNil predicate on the "import_ref" field.
func ImportRefIsNil() predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.IsNull(s.C(FieldImportRef)))
})
}
// ImportRefNotNil applies the NotNil predicate on the "import_ref" field.
func ImportRefNotNil() predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.NotNull(s.C(FieldImportRef)))
})
}
// ImportRefEqualFold applies the EqualFold predicate on the "import_ref" field.
func ImportRefEqualFold(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.EqualFold(s.C(FieldImportRef), v))
})
}
// ImportRefContainsFold applies the ContainsFold predicate on the "import_ref" field.
func ImportRefContainsFold(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {
s.Where(sql.ContainsFold(s.C(FieldImportRef), v))
})
}
// NotesEQ applies the EQ predicate on the "notes" field.
func NotesEQ(v string) predicate.Item {
return predicate.Item(func(s *sql.Selector) {