Skip to content
Collec-Science

Collec-Science

Stock and find yours samples!

  • Presentation
  • Install – update
  • Usage
  • Knowledge base
  • Community
  • EnglishEnglish
    • FrançaisFrançais
    • EnglishEnglish

Rename a metadata field

  • Home
  • usage_en
  • Rename a metadata field
Rename a metadata field
23 March 202123 March 2021 Eric Quinton

Presentation

The metadata describing the samples are stored in a field in JSON format. If it allows a great flexibility (possibility of adding fields very easily), it also has its own limits.

The editor used in the software to modify the metadata will completely rewrite the content of the JSON field. If the field contained a previously unknown field in the model, it will be lost. In order to modify the name of a field, we must therefore proceed in several steps.

Let’s imagine that we want to rename the field “espece” to “species”.

First step: rename the field in the database

With an SQL editor, we will first check the renaming operation before executing it:

select sample_id, metadata, metadata -> 'espece',
jsonb_insert(metadata::jsonb, '{"species"}'::text[], (metadata->'espece' )::jsonb) - 'espece'
from col.sample 
where metadata ->> 'espece' is not null;

The query allows to add a field “species” whose content is ‘espece’ (jsonb_insert), then to remove the field ‘espece’ (- ‘espece’).

To update the data, you just have to modify the query as follows:

update col.sample 
set metadata = jsonb_insert(metadata::jsonb, '{"species"}'::text[], (metadata->'espece' )::jsonb) - 'espece'
where metadata ->> 'espece' is not null;

Second step: modify the corresponding metadata template(s)

In the software, edit the metadata template(s) to rename the ‘espece’ field to ‘species’.

You can quickly view the list of metadata templates that contain the relevant label:

select metadata_id, metadata_name, metadata_schema
from col.metadata
where metadata_schema::text like '%espece%';

Translated with www.DeepL.com/Translator (free version)

documentation_en, knowledge base, metadata, support_en, usage, usage_en, usage_en

Post navigation

Version 2.5.0 of November 13, 2020
Lend one or more samples

Recent posts

  • Version 2.6.0 of june 24, 2021
  • Lend one or more samples
  • Rename a metadata field
  • Version 2.5.0 of November 13, 2020
  • Export the collections of samples to other repositories

About Collec-Science

Collec-Science is a tracking software for samples collected as part of scientific experiments. It lets you know where they are stored, who used them, what they became. Open-source software distributed under the AGPL license, Collec-Science was created by INRAE (research unit Aquatic Ecosystems and Global Changes in Bordeaux), and is subject to adaptations within the framework of CNRS workshops ( http://www.cnrs.fr/inee/tools/za_5.html ) , especially to fill in the information directly in the field.

Contact

INRAE © 2017-2021
Project coordinator: Eric Quinton
Phone:+33 (0) 5 57 89 27 10
Email: eric.quinton[at]inrae.fr
Website: www.inrae.fr
Site design: Gregory Lambert
Crédits photos:
Copyright © 2022 Collec-Science All rights reserved. Theme: Flash by ThemeGrill. Powered by WordPress