Skip to content

Commit

Permalink
Document the $inline tag (#285)
Browse files Browse the repository at this point in the history
fixes #284
  • Loading branch information
fmoor authored Sep 27, 2023
1 parent 9d0e3ed commit f48673f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
15 changes: 14 additions & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
// query results. The edgedb.Optional struct can be embedded to make structs
// optional.
//
// type User Struct {
// type User struct {
// edgedb.Optional
// Email string `edgedb:"email"`
// }
Expand All @@ -154,6 +154,19 @@
// Nested structures are also not directly allowed but you can use [json]
// instead.
//
// By default EdgeDB will ignore embedded structs when marshaling/unmarshaling.
// To treat an embedded struct's fields as part of the parent struct's fields,
// tag the embedded struct with `edgedb:"$inline"`.
//
// type Object struct {
// ID edgedb.UUID
// }
//
// type User struct {
// Object `edgedb:"$inline"`
// Name string
// }
//
// # Custom Marshalers
//
// Interfaces for user defined marshaler/unmarshalers are documented in the
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/gendocs/rstprinter.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,6 @@ func (p *rstPrinter) text(out *bytes.Buffer, x []comment.Text) {
func (p *rstPrinter) escape(out *bytes.Buffer, s string) {
s = strings.ReplaceAll(s, "*", "\\*")
s = strings.ReplaceAll(s, "\\\\*", "\\*")
s = strings.ReplaceAll(s, "`", "\\`")
out.WriteString(s)
}
17 changes: 16 additions & 1 deletion rstdocs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ optional.

.. code-block:: go
type User Struct {
type User struct {
edgedb.Optional
Email string `edgedb:"email"`
}
Expand All @@ -174,6 +174,21 @@ using sets as parameters.
Nested structures are also not directly allowed but you can use `json <https://www.edgedb.com/docs/edgeql/insert#bulk-inserts>`_
instead.

By default EdgeDB will ignore embedded structs when marshaling/unmarshaling.
To treat an embedded struct's fields as part of the parent struct's fields,
tag the embedded struct with \`edgedb:"$inline"\`.

.. code-block:: go
type Object struct {
ID edgedb.UUID
}
type User struct {
Object `edgedb:"$inline"`
Name string
}
Custom Marshalers
-----------------
Expand Down

0 comments on commit f48673f

Please sign in to comment.