########
Metadata
########

Overview
========


Properties and user data are two different ways of storing metadata in a model. Properties are key value pairs. User data is arbitrary binary data. Each :ref:`NodeId <api_ref/viewing/modules/Communicator:nodeid>` can be associated with multiple properties and user data. For example, you can use properties to associate a ``NodeId`` with a manufacturing ID and a revision date, or user data to associate a ``NodeId`` with an image.

While we do not cover adding user data in this guide, user data can be added when the model is authored, or inferred when the model is converted.


Retrieving properties
=====================

To retrieve a node's properties, you can use the :ref:`Model.getNodeProperties() <api_ref/viewing/classes/Communicator.Model:getnodeproperties>` function. This will return a list of key value pairs associated with the given ``NodeId``.

.. literalinclude:: /../../applications/client/docs/PG_Metadata.ts
	   :start-after: //! [metadata_properties]
	   :end-before: //! [metadata_properties]


Retrieving user data
====================

To retrieve a node's user data, you can use the :ref:`Model.getNodeUserDataIndices() <api_ref/viewing/classes/Communicator.Model:getnodeuserdataindices>` function. This will return a list of user data indices. The list of indices can be used to iterate and retrieve the data with the :ref:`Model.getNodeUserData() <api_ref/viewing/classes/Communicator.Model:getnodeuserdata>` function, which returns a `Uint8Array <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array>`_ containing the data.
