aboutsummaryrefslogtreecommitdiff
path: root/docs/source/user/moving_data_between_collections.rst
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2020-10-08 20:42:54 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2020-10-08 20:42:54 +0200
commit54185616ef81fa1da57b3d3bad4d9f5f71c0b07c (patch)
treebb0e6892a787bcb32fff151d65406f7f8d28f8f0 /docs/source/user/moving_data_between_collections.rst
parent6e454378b939d8beeba26e59cb49d130307f93db (diff)
Split documentation by target
Diffstat (limited to 'docs/source/user/moving_data_between_collections.rst')
-rw-r--r--docs/source/user/moving_data_between_collections.rst41
1 files changed, 41 insertions, 0 deletions
diff --git a/docs/source/user/moving_data_between_collections.rst b/docs/source/user/moving_data_between_collections.rst
new file mode 100644
index 0000000..23c693e
--- /dev/null
+++ b/docs/source/user/moving_data_between_collections.rst
@@ -0,0 +1,41 @@
+*******************************
+Moving Data between Collections
+*******************************
+
+Entries can be exported from a lesana collection to another using the
+``lesana export`` command and a jinja2 template.
+
+The template should generate a yaml file that is a valid lesana entry
+for the destination collection and it can use the fields of the starting
+collection as variables. The variable ``entry`` is also available and
+gives complete access to the entry of the original collection, so fields
+with names that aren't valid jinja templates can be accessed as
+``entry.data[<field-name>]``.
+
+E.g. to convert between a collection with fields ``name``,
+``short-desc``, ``desc`` to a collection with fields ``name``,
+``description`` one could use the following template::
+
+ name: {{ name }}
+ description: |
+ {{ entry.data.[short-desc] }}
+
+ {{ desc | indent(width=4, first=False) }}
+
+From the origin collection you can then run the command::
+
+ lesana export <path/to/destination/collection> <path/to/template>
+
+to export all entries.
+
+You can also export just a subset of entries by adding a xapian query
+with the parameter ``--query``; you can test the search using::
+
+ lesana search --all <some search terms>
+
+and then actually run the export with::
+
+ lesana search --query '<some search terms>' <destination> <template>
+
+note that in this second command the spaces in the search query have to
+be protected from the shell.