rename token root to data_root. using meta v3
This commit is contained in:
parent
04c5376009
commit
d8eaa98d13
|
@ -40,7 +40,7 @@ function supported_tokens()
|
|||
'table_pkey',
|
||||
'table_json_kv',
|
||||
|
||||
'root',
|
||||
'data_root',
|
||||
'bitfields',
|
||||
'diffable',
|
||||
'diff_removed',
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"git.bit5.ru/backend/meta/v2"
|
||||
"git.bit5.ru/backend/meta/v3"
|
||||
"git.bit5.ru/backend/versioning"
|
||||
"git.bit5.ru/gomodules/metadb"
|
||||
"github.com/go-logr/logr"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if has_token(s, 'root') %}
|
||||
{% if has_token(s, 'data_root') %}
|
||||
{{ _self.root_save(s) }}
|
||||
{{ _self.root_delete(s) }}
|
||||
{{ _self.root_save_diff(s) }}
|
||||
|
@ -223,7 +223,7 @@ func Save{{ s.name }}Diff(ctx context.Context, dbe metadb.Execer, rec {{ s.name
|
|||
|
||||
|
||||
{% macro root_delete(s) %}
|
||||
{% set delete_by = meta_field(token(s, 'root')) %}
|
||||
{% set delete_by = meta_field(token(s, 'data_root')) %}
|
||||
func Delete{{ s.name }}(ctx context.Context, dbe metadb.Execer, {{ delete_by|varname }} {{ delete_by.type|go_type }}) error {
|
||||
{%~ for f in s.fields %}
|
||||
{%~ if f.type is array %}
|
||||
|
@ -727,7 +727,7 @@ func (s *{{ name|default(s.name) }}) ReadFields(reader meta.Reader) error {
|
|||
|
||||
{% macro meta_write(o, name) %}
|
||||
func (s *{{ name|default(o.name) }}) Write(writer meta.Writer) error {
|
||||
if err := writer.BeginAssocContainer({{ get_all_fields(o)|length }}, ""); err != nil {
|
||||
if err := writer.BeginContainer({{ get_all_fields(o)|length }}, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.WriteFields(writer); err != nil {
|
||||
|
@ -762,7 +762,7 @@ func (s *{{ name|default(o.name) }}) WriteFields(writer meta.Writer) error {
|
|||
return err
|
||||
}
|
||||
{% elseif type is struct %}
|
||||
if err := writer.BeginAssocContainer({{ get_all_fields(type)|length }}, "{{ alias }}"); err != nil {
|
||||
if err := writer.BeginContainer({{ get_all_fields(type)|length }}, "{{ alias }}"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := {{ fname }}.WriteFields(writer); err != nil {
|
||||
|
@ -772,13 +772,13 @@ func (s *{{ name|default(o.name) }}) WriteFields(writer meta.Writer) error {
|
|||
return err
|
||||
}
|
||||
{% elseif type is array %}
|
||||
if err := writer.BeginContainer(len({{ fname }}), "{{ alias }}"); err != nil {
|
||||
if err := writer.BeginCollection(len({{ fname }}), "{{ alias }}"); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, v := range {{ fname }} {
|
||||
{{ _self.meta_write_field(type.value, 'v') }}
|
||||
}
|
||||
if err := writer.EndContainer(); err != nil {
|
||||
if err := writer.EndCollection(); err != nil {
|
||||
return err
|
||||
}
|
||||
{% else %}
|
||||
|
|
Loading…
Reference in New Issue