fix #16: add documentation about how to use .Created.AsTime (#18)

Co-authored-by: Thomas von Dein <tom@vondein.org>
This commit is contained in:
T.v.Dein
2025-02-03 17:50:28 +01:00
committed by GitHub
parent bd5c1e3abb
commit bc1b08d6f9
3 changed files with 15 additions and 11 deletions

View File

@@ -448,17 +448,20 @@ The following template variables can be used:
=over
=item B<Key> - string
=item B<.Key> - string
=item B<Value> - string
=item B<.Value> - string
=item B<Bin> - []byte
=item B<.Bin> - []byte
=item B<Created> - time.Time
=item B<.Created> - timestamp.Time
=item B<Tags> - []string
To retrieve a string representation of the timestamp, use C<.Created.AsTime>.
If you need a unix timestamp since epoch, use C<.Created.Unix>.
=item B<Encrypted> bool
=item B<.Tags> - []string
=item B<.Encrypted> bool
=back
@@ -473,12 +476,12 @@ Only show the keys of all entries:
Format the list in a way so that is possible to evaluate it in a
shell:
eval $(anydb get foo -m template -T "key='{{ .Key }}' value='{{ .Value }}' ts='{{ .Created}}'")
echo "Key: $key, Value: $value"
eval $(anydb get foo -m template -T "key='{{ .Key }}' value='{{ .Value }}' ts='{{ .Created.AsTime}}'")
echo "Key: $key, Value: $value, When: $ts"
Print the values in CSV format ONLY if they have some tag:
anydb list -m template -T "{{ if .Tags }}{{ .Key }},{{ .Value }},{{ .Created}}{{ end }}"
anydb list -m template -T "{{ if .Tags }}{{ .Key }},{{ .Value }},{{ .Created.AsTime}}{{ end }}"
=head1 CONFIGURATION