Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add json #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions langs/go/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,21 +432,21 @@ func (m *GoModeler) fields(structName string, fields []*firemodel.SchemaField, a
g.
Id(strcase.ToCamel(field.Name)).
Do(m.goType(field.Type)).
Tag(map[string]string{"firestore": m.fieldTags(field)})
Tag(map[string]string{"firestore": m.fieldTags(field), "json": m.fieldTags(field)})
}
if addTimestampFields {
g.Line()
g.Comment("Creation timestamp.")
g.
Id("CreatedAt").
Qual("time", "Time").
Tag(map[string]string{"firestore": "createdAt"})
Tag(map[string]string{"firestore": "createdAt", "json": "createdAt"})

g.Comment("Update timestamp.")
g.
Id("UpdatedAt").
Qual("time", "Time").
Tag(map[string]string{"firestore": "updatedAt"})
Tag(map[string]string{"firestore": "updatedAt", "json": "updatedAt"})
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ package firemodel
// TODO: Add comment to Test in firemodel schema.
type Test struct {
// TODO: Add comment to Test.direction.
Direction TestEnum `firestore:"direction,omitempty"`
Direction TestEnum `firestore:"direction,omitempty" json:"direction,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,56 +18,56 @@ import (
// Firestore document location: /users/{user_id}/test_models/{test_model_id}
type TestModel struct {
// The name.
Name string `firestore:"name,omitempty"`
Name string `firestore:"name,omitempty" json:"name,omitempty"`
// The age.
Age int64 `firestore:"age"`
Age int64 `firestore:"age" json:"age"`
// The number pi.
Pi float64 `firestore:"pi"`
Pi float64 `firestore:"pi" json:"pi"`
// The birth date.
Birthdate time.Time `firestore:"birthdate,omitempty"`
Birthdate time.Time `firestore:"birthdate,omitempty" json:"birthdate,omitempty"`
// True if it is good.
IsGood bool `firestore:"isGood"`
IsGood bool `firestore:"isGood" json:"isGood"`
// TODO: Add comment to TestModel.data.
Data []byte `firestore:"data,omitempty"`
Data []byte `firestore:"data,omitempty" json:"data,omitempty"`
// TODO: Add comment to TestModel.friend.
Friend *firestore.DocumentRef `firestore:"friend,omitempty"`
Friend *firestore.DocumentRef `firestore:"friend,omitempty" json:"friend,omitempty"`
// TODO: Add comment to TestModel.location.
Location *latlng.LatLng `firestore:"location,omitempty"`
Location *latlng.LatLng `firestore:"location,omitempty" json:"location,omitempty"`
// TODO: Add comment to TestModel.colors.
Colors []string `firestore:"colors,omitempty"`
Colors []string `firestore:"colors,omitempty" json:"colors,omitempty"`
// TODO: Add comment to TestModel.numbers.
Numbers []int64 `firestore:"numbers,omitempty"`
Numbers []int64 `firestore:"numbers,omitempty" json:"numbers,omitempty"`
// TODO: Add comment to TestModel.bools.
Bools []bool `firestore:"bools,omitempty"`
Bools []bool `firestore:"bools,omitempty" json:"bools,omitempty"`
// TODO: Add comment to TestModel.doubles.
Doubles []float64 `firestore:"doubles,omitempty"`
Doubles []float64 `firestore:"doubles,omitempty" json:"doubles,omitempty"`
// TODO: Add comment to TestModel.directions.
Directions []TestEnum `firestore:"directions,omitempty"`
Directions []TestEnum `firestore:"directions,omitempty" json:"directions,omitempty"`
// TODO: Add comment to TestModel.models.
Models []*TestStruct `firestore:"models,omitempty"`
Models []*TestStruct `firestore:"models,omitempty" json:"models,omitempty"`
// TODO: Add comment to TestModel.models_2.
Models2 []*TestStruct `firestore:"models2,omitempty"`
Models2 []*TestStruct `firestore:"models2,omitempty" json:"models2,omitempty"`
// TODO: Add comment to TestModel.refs.
Refs []*firestore.DocumentRef `firestore:"refs,omitempty"`
Refs []*firestore.DocumentRef `firestore:"refs,omitempty" json:"refs,omitempty"`
// TODO: Add comment to TestModel.model_refs.
ModelRefs []*firestore.DocumentRef `firestore:"modelRefs,omitempty"`
ModelRefs []*firestore.DocumentRef `firestore:"modelRefs,omitempty" json:"modelRefs,omitempty"`
// TODO: Add comment to TestModel.meta.
Meta map[string]interface{} `firestore:"meta,omitempty"`
Meta map[string]interface{} `firestore:"meta,omitempty" json:"meta,omitempty"`
// TODO: Add comment to TestModel.meta_strs.
MetaStrs map[string]string `firestore:"metaStrs,omitempty"`
MetaStrs map[string]string `firestore:"metaStrs,omitempty" json:"metaStrs,omitempty"`
// TODO: Add comment to TestModel.direction.
Direction TestEnum `firestore:"direction,omitempty"`
Direction TestEnum `firestore:"direction,omitempty" json:"direction,omitempty"`
// TODO: Add comment to TestModel.test_file.
TestFile *runtime.File `firestore:"testFile,omitempty"`
TestFile *runtime.File `firestore:"testFile,omitempty" json:"testFile,omitempty"`
// TODO: Add comment to TestModel.url.
Url runtime.URL `firestore:"url,omitempty"`
Url runtime.URL `firestore:"url,omitempty" json:"url,omitempty"`
// TODO: Add comment to TestModel.nested.
Nested *TestStruct `firestore:"nested,omitempty"`
Nested *TestStruct `firestore:"nested,omitempty" json:"nested,omitempty"`

// Creation timestamp.
CreatedAt time.Time `firestore:"createdAt"`
CreatedAt time.Time `firestore:"createdAt" json:"createdAt"`
// Update timestamp.
UpdatedAt time.Time `firestore:"updatedAt"`
UpdatedAt time.Time `firestore:"updatedAt" json:"updatedAt"`
}

// TestModelPath returns the path to a particular TestModel in Firestore.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ package firemodel
// TODO: Add comment to TestStruct in firemodel schema.
type TestStruct struct {
// TODO: Add comment to TestStruct.where.
Where string `firestore:"where,omitempty"`
Where string `firestore:"where,omitempty" json:"where,omitempty"`
// TODO: Add comment to TestStruct.how_much.
HowMuch int64 `firestore:"howMuch"`
HowMuch int64 `firestore:"howMuch" json:"howMuch"`
// TODO: Add comment to TestStruct.some_enum.
SomeEnum TestEnum `firestore:"someEnum,omitempty"`
SomeEnum TestEnum `firestore:"someEnum,omitempty" json:"someEnum,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
type TestTimestamps struct {

// Creation timestamp.
CreatedAt time.Time `firestore:"createdAt"`
CreatedAt time.Time `firestore:"createdAt" json:"createdAt"`
// Update timestamp.
UpdatedAt time.Time `firestore:"updatedAt"`
UpdatedAt time.Time `firestore:"updatedAt" json:"updatedAt"`
}

// TestTimestampsPath returns the path to a particular TestTimestamps in Firestore.
Expand Down