{"result":{"depiction_url":null,"edges":{"hasreference":{"objects":[{"created":"2026-10-07T11:13:48Z","object_id":{"id":2950,"is_a":["text","documentation","developerguide"],"name":"developer_resource_identifiers","title":{"_type":"trans","tr":{"en":"Use stable resource names"}},"uri":"https:\/\/zotonic.com\/id\/2950"},"seq":1},{"created":"2026-10-07T11:13:48Z","object_id":{"id":2951,"is_a":["text","documentation","developerguide"],"name":"developer_resource_properties","title":{"_type":"trans","tr":{"en":"Read and update resource properties"}},"uri":"https:\/\/zotonic.com\/id\/2951"},"seq":2},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2953,"is_a":["text","documentation","developerguide"],"name":"developer_content_edges","title":{"_type":"trans","tr":{"en":"Connect resources and preserve order"}},"uri":"https:\/\/zotonic.com\/id\/2953"},"seq":3}],"predicate":{"id":2774,"is_a":["meta","predicate"],"name":"hasreference","title":{"_type":"trans","tr":{"en":"Documentation reference"}},"uri":"https:\/\/zotonic.com\/id\/hasreference"}},"references":{"objects":[{"created":"2020-05-30T05:47:15Z","object_id":{"id":1277,"is_a":["text","documentation","userguide"],"name":"doc_userguide_datamodel","title":{"_type":"trans","tr":{"en":"Understand pages and connections"}},"uri":"https:\/\/zotonic.com\/id\/1277"},"seq":1000000},{"created":"2020-05-30T05:47:15Z","object_id":{"id":1278,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_rsc","title":"rsc","uri":"https:\/\/zotonic.com\/id\/1278"},"seq":1000000},{"created":"2020-05-30T05:47:15Z","object_id":{"id":1279,"is_a":["text","documentation"],"name":"doc_glossary","title":"Glossary","uri":"https:\/\/zotonic.com\/id\/1279"},"seq":1000000},{"created":"2020-05-30T05:47:16Z","object_id":{"id":1280,"is_a":["text","documentation","developerguide"],"name":"doc_developerguide_media","title":{"_type":"trans","tr":{"en":"Render and manage media"}},"uri":"https:\/\/zotonic.com\/id\/1280"},"seq":1000000},{"created":"2020-05-30T05:47:16Z","object_id":{"id":1281,"is_a":["text","documentation","cookbook"],"name":"doc_cookbook_custom_pivot","title":{"_type":"trans","tr":{"en":"Index a custom resource property"}},"uri":"https:\/\/zotonic.com\/id\/1281"},"seq":1000000},{"created":"2020-05-30T05:47:16Z","object_id":{"id":1282,"is_a":["text","documentation","cookbook"],"name":"doc_cookbook_pivot_templates","title":{"_type":"trans","tr":{"en":"Pivot Templates"}},"uri":"https:\/\/zotonic.com\/id\/1282"},"seq":1000000}],"predicate":{"id":332,"is_a":["meta","predicate"],"name":"references","title":{"_type":"trans","tr":{"en":"References"}},"uri":"https:\/\/zotonic.com\/id\/references"}},"refers":{"objects":[{"created":"2026-10-07T11:13:00Z","object_id":{"id":1278,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_rsc","title":"rsc","uri":"https:\/\/zotonic.com\/id\/1278"},"seq":1000000},{"created":"2026-10-07T11:13:00Z","object_id":{"id":1297,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_edge","title":"edge","uri":"https:\/\/zotonic.com\/id\/1297"},"seq":1000000},{"created":"2026-10-07T11:13:00Z","object_id":{"id":2955,"is_a":["text","documentation","developerguide"],"name":"developer_datamodel_fixtures","title":{"_type":"trans","tr":{"en":"Install initial content with a datamodel"}},"uri":"https:\/\/zotonic.com\/id\/2955"},"seq":1000000},{"created":"2026-10-07T11:13:00Z","object_id":{"id":2957,"is_a":["text","documentation","developerguide"],"name":"developer_import_export","title":{"_type":"trans","tr":{"en":"Move content between sites"}},"uri":"https:\/\/zotonic.com\/id\/2957"},"seq":1000000}],"predicate":{"id":2409,"is_a":["meta","predicate"],"name":"refers","title":{"_type":"trans","tr":{"en":"Refers"}},"uri":"https:\/\/zotonic.com\/id\/refers"}},"relation":{"objects":[{"created":"2020-05-30T05:47:16Z","object_id":{"id":1283,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_category","title":"category","uri":"https:\/\/zotonic.com\/id\/1283"},"seq":1000000},{"created":"2020-05-30T05:47:16Z","object_id":{"id":1284,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_media","title":"media","uri":"https:\/\/zotonic.com\/id\/1284"},"seq":1000000},{"created":"2020-05-30T05:47:16Z","object_id":{"id":1278,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_rsc","title":"rsc","uri":"https:\/\/zotonic.com\/id\/1278"},"seq":1000000},{"created":"2020-05-30T05:47:16Z","object_id":{"id":1285,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_identity","title":"identity","uri":"https:\/\/zotonic.com\/id\/1285"},"seq":1000000},{"created":"2020-05-30T05:47:16Z","object_id":{"id":1286,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_rsc_gone","title":"rsc_gone","uri":"https:\/\/zotonic.com\/id\/1286"},"seq":1000000}],"predicate":{"id":303,"is_a":["meta","predicate"],"name":"relation","title":{"_type":"trans","tr":{"nl":"Relatie","en":"Relation"}},"uri":"http:\/\/purl.org\/dc\/terms\/relation"}},"subject":{"objects":[{"created":"2026-10-07T11:13:49Z","object_id":{"id":2554,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_how_to_guide","title":"How-to guide","uri":"https:\/\/zotonic.com\/id\/2554"},"seq":1},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2564,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_backend_developer","title":"Backend developer","uri":"https:\/\/zotonic.com\/id\/2564"},"seq":2},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2614,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_resource","title":"Resource","uri":"https:\/\/zotonic.com\/id\/2614"},"seq":3},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2568,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_content_modeling","title":"Content modeling","uri":"https:\/\/zotonic.com\/id\/2568"},"seq":4},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2574,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_content_relationships","title":"Content relationships","uri":"https:\/\/zotonic.com\/id\/2574"},"seq":5}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":1276,"is_a":["text","documentation","developerguide"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1276"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_developerguide_resources","page_url":{"en":"https:\/\/zotonic.com\/docs\/1276\/use-stable-resource-names","x-default":"https:\/\/zotonic.com\/docs\/1276\/use-stable-resource-names"},"preview_url":null,"resource":{"body":{"_type":"trans","tr":{"en":"<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">Id = m_rsc:rid(page_home, C).\n<\/code><\/pre>\n<p>Check the result before using it: that name may not exist on your site. A database ID copied from another site can identify unrelated content. Use a stable name, URI, or explicit import mapping when moving data between sites.<\/p>\n<p>Reserve names for resources your application can identify consistently. Editors can still manage their titles and bodies. See <a href=\"\/id\/1278\" class=\"doc-reference doc-reference-model\"><code>model#rsc<\/code><\/a>, <a href=\"\/id\/2955\">Install initial content with a datamodel<\/a>, and <a href=\"\/id\/2957\">Move content between sites<\/a>.<\/p>\n<h2>Read and update resource properties<\/h2>\n<p>Use <a href=\"\/id\/1278\" class=\"doc-reference doc-reference-model\"><code>model#rsc<\/code><\/a> to read resources and <code>m_rsc_update<\/code> for writes. Use the supplied request context so the operation keeps the caller&#39;s site and permissions.<\/p>\n<p>In an authorized local test context, with an existing <code>garden_welcome<\/code> resource:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">Id = m_rsc:rid(garden_welcome, C).\nm_rsc:is_visible(Id, C).\nm_rsc:p(Id, title, C).\nm_rsc_update:update(Id, #{&lt;&lt;&quot;summary&quot;&gt;&gt; =&gt; &lt;&lt;&quot;Visit the garden on Saturday.&quot;&gt;&gt;}, C).\n<\/code><\/pre>\n<p>Check that <code>Id<\/code> is an integer before continuing. Expect <code>{ok, Id}<\/code> from a successful update; <code>{error, Reason}<\/code> is a failed write, not a saved page. Read the summary back and check the rendered page. The ordinary <code>z:c(garden)<\/code> shell context does not grant editing permission.<\/p>\n<p>In application code, branch on visibility before returning private properties and on the update result before reporting success. The write API checks access, but you must still select and validate the fields the caller may change. Do not copy every submitted field into the resource or update the SQL table directly.<\/p>\n<h2>Connect resources and preserve order<\/h2>\n<p>An edge connects a subject resource to an object resource through a predicate. Use <a href=\"\/id\/1297\" class=\"doc-reference doc-reference-model\"><code>model#edge<\/code><\/a> to inspect and manage these connections.<\/p>\n<p>For example, in a local shell:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">m_edge:objects(Id, haspart, C).\n<\/code><\/pre>\n<p>Use the edge API for insertions, deletions, and ordering. Direct database writes skip normal notifications and cache invalidation. Check permissions on the requested relationship as well as the resource being edited.<\/p>\n<p>When importing a collection, preserve the order of its children explicitly. A set of correct connections in the wrong order can still produce the wrong navigation. See <a href=\"\/id\/2957\">Move content between sites<\/a> and <a href=\"\/id\/2955\">Install initial content with a datamodel<\/a>.<\/p>\n<p>For two existing, authorized resources, connect a guide to its first task:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{ok, _EdgeId} = m_edge:insert(GuideId, haspart, TaskId, C).\nm_edge:objects(GuideId, haspart, C).\n<\/code><\/pre>\n<p>The pattern match is useful in a test shell; application code must handle <code>{error, Reason}<\/code>. Use <code>relation<\/code> for related tasks and a site&#39;s <code>hasreference<\/code> predicate for citations, when that predicate exists. Neither should change collection membership.<\/p>\n<p><code>m_edge:set_sequence(GuideId, haspart, OrderedIds, C)<\/code> sets the requested outgoing list; it can add or remove membership as well as reorder it. Read the current list first and supply the complete intended list. Verify it with <code>m_edge:objects\/3<\/code>. Do not use this operation to overwrite connections owned by editors during a routine import.<\/p>"}},"category_id":{"id":317,"is_a":["meta","category"],"name":"developerguide","title":"Developer guide","uri":"https:\/\/zotonic.com\/id\/developerguide"},"content_group_id":{"id":339,"is_a":["meta","content_group"],"name":"default_content_group","title":{"_type":"trans","tr":{"en":"Default Content Group"}},"uri":"https:\/\/zotonic.com\/id\/default_content_group"},"created":"2020-05-30T05:47:15Z","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"doc_editorial_bundle":true,"doc_editorial_edges":{"hasreference":[2950,2951,2953],"subject":[2554,2564,2568,2574,2614]},"github_url":"https:\/\/github.com\/zotonic\/zotonic\/tree\/master\/doc\/developer-guide\/resources.rst","is_authoritative":true,"is_dependent":false,"is_featured":false,"is_protected":false,"is_published":true,"is_unfindable":false,"language":["en"],"modified":"2026-10-07T20:45:37Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"name":"doc_developerguide_resources","pivot_geocode":null,"pivot_location_lat":null,"pivot_location_lng":null,"privacy":0,"publication_end":"9999-06-01T00:00:00Z","publication_start":"2022-02-15T10:01:42Z","slug":"use-stable-resource-names","summary":{"_type":"trans","tr":{"en":"A resource has a numeric ID within its database. Give application-owned resources a stable name when code needs to find them across installations."}},"title":{"_type":"trans","tr":{"en":"Use stable resource names"}},"title_slug":{"_type":"trans","tr":{"en":"use-stable-resource-names"}},"tz":"UTC","uri":null,"version":41,"visible_for":0},"uri":"https:\/\/zotonic.com\/id\/1276","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1276"}},"status":"ok"}