{"id":619,"date":"2023-10-23T10:47:52","date_gmt":"2023-10-23T08:47:52","guid":{"rendered":"http:\/\/eines-informatiques.recursos.uoc.edu\/gestion-de-datos\/?page_id=619"},"modified":"2025-07-26T18:58:56","modified_gmt":"2025-07-26T16:58:56","slug":"2-8-eliminar-documents","status":"publish","type":"page","link":"http:\/\/eines-informatiques.recursos.uoc.edu\/gestion-de-datos\/2-8-eliminar-documents\/","title":{"rendered":"2.8. Eliminar documents"},"content":{"rendered":"<p>Vegem ara com podem eliminar un document de la col\u00b7lecci\u00f3 amb la funci\u00f3 <code>remove()<\/code>.<\/p>\n<p>Eliminem de la col\u00b7lecci\u00f3 el document amb el nom de gen <strong>uc001aaa.3<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mariadb\" data-enlighter-theme=\"mowtwo\">db.chr1.remove( { \"name\" : \"uc001aaa.3\"});<\/pre>\n<p>I comprovem si el document s\u2019ha eliminat:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mariadb\" data-enlighter-theme=\"mowtwo\">db.chr1.find().pretty();\u00a0\r\n<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mariadb\" data-enlighter-theme=\"mowtwo\">&gt; db.chr1.remove( { \"name\" : \"uc001aaa.3\"});\r\nWriteResult({ \"nRemoved\" : 1 })\r\n&gt; db.chr1.find().pretty();\r\n{\r\n        \"_id\" : ObjectId(\"6487c410235597cf4bc92782\"),\r\n        \"name\" : \"uc010nxr.1\",\r\n        \"chrom\" : \"chr1\",\r\n        \"strand\" : \"+\",\r\n        \"txStart\" : 11873,\r\n        \"txEnd\" : 14409,\r\n        \"cdsStart\" : 11873,\r\n        \"cdsEnd\" : 11873,\r\n        \"exonCount\" : 3,\r\n        \"exonStarts\" : \"11873,12645,13220,\",\r\n        \"exonEnds\" : \"12227,12697,14409,\",\r\n        \"proteinID\" : \"\",\r\n        \"alignID\" : \"uc010nxr.1\"\r\n}\r\n{\r\n        \"_id\" : ObjectId(\"6487c41c235597cf4bc92783\"),\r\n        \"name\" : \"uc009vit.3\",\r\n        \"chrom\" : \"chr1\",\r\n        \"strand\" : \"-\",\r\n        \"txStart\" : 14361,\r\n        \"txEnd\" : 19759,\r\n        \"cdsStart\" : 14361,\r\n        \"cdsEnd\" : 14361,\r\n        \"exonCount\" : 9,\r\n        \"exonStarts\" : \"14361,14969,15795,16606,16857,17232,17914,18267,18912,\",\r\n        \"exonEnds\" : \"14829,15038,15947,16765,17055,17742,18061,18366,19759,\",\r\n        \"proteinID\" : \"\",\r\n        \"alignID\" : \"uc009vit.3\"\r\n}<\/pre>\n<p>Ara eliminarem tota la col\u00b7lecci\u00f3 amb l\u2019ordre <code>drop<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mariadb\" data-enlighter-theme=\"mowtwo\">db.dropDatabase();<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Vegem ara com podem eliminar un document de la col\u00b7lecci\u00f3 amb la funci\u00f3 remove(). Eliminem de la col\u00b7lecci\u00f3 el document amb el nom de gen uc001aaa.3 db.chr1.remove( { &#8220;name&#8221; : &#8220;uc001aaa.3&#8221;}); I comprovem si el document s\u2019ha eliminat: db.chr1.find().pretty();\u00a0 &gt; db.chr1.remove( { &#8220;name&#8221; : &#8220;uc001aaa.3&#8221;}); WriteResult({ &#8220;nRemoved&#8221; : 1 }) &gt; db.chr1.find().pretty(); { &#8220;_id&#8221; : [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"acf":[],"_links":{"self":[{"href":"http:\/\/eines-informatiques.recursos.uoc.edu\/gestion-de-datos\/wp-json\/wp\/v2\/pages\/619"}],"collection":[{"href":"http:\/\/eines-informatiques.recursos.uoc.edu\/gestion-de-datos\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/eines-informatiques.recursos.uoc.edu\/gestion-de-datos\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/eines-informatiques.recursos.uoc.edu\/gestion-de-datos\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/eines-informatiques.recursos.uoc.edu\/gestion-de-datos\/wp-json\/wp\/v2\/comments?post=619"}],"version-history":[{"count":7,"href":"http:\/\/eines-informatiques.recursos.uoc.edu\/gestion-de-datos\/wp-json\/wp\/v2\/pages\/619\/revisions"}],"predecessor-version":[{"id":1061,"href":"http:\/\/eines-informatiques.recursos.uoc.edu\/gestion-de-datos\/wp-json\/wp\/v2\/pages\/619\/revisions\/1061"}],"wp:attachment":[{"href":"http:\/\/eines-informatiques.recursos.uoc.edu\/gestion-de-datos\/wp-json\/wp\/v2\/media?parent=619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}