{"id":4483,"date":"2021-06-17T13:36:05","date_gmt":"2021-06-17T11:36:05","guid":{"rendered":"https:\/\/arduino.net.pl\/?page_id=4483"},"modified":"2021-06-17T14:35:32","modified_gmt":"2021-06-17T12:35:32","slug":"firebase-json-2","status":"publish","type":"page","link":"https:\/\/arduino.net.pl\/index.php\/arduino-ide\/firebase-json-2\/","title":{"rendered":"Firebase"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Do\u0142\u0105czanie danych<\/h2>\n\n\n\n<p>Aby doda\u0107 nowe dane do okre\u015blonego w\u0119z\u0142a w Firebase RTDB, u\u017cyj funkcji push.<br>W\u015br\u00f3d funkcji dost\u0119pne s\u0105: <strong>push, pushInt, pushFloat, pushDouble, pushBool, pushString, pushJSON, pushArray, pushBlob <\/strong>oraz<strong> pushFile<\/strong>.<br>Funkcje te zwracaj\u0105 warto\u015b\u0107 <strong>boolean<\/strong> wskazuj\u0105c\u0105 na powodzenie lub nie operacji.<br>Unikalny klucz nowo do\u0142\u0105czanego w\u0119z\u0142a mo\u017ce by\u0107 okre\u015blony funkcj\u0105 <strong>fbdo.pushName<\/strong>.<br>Podobnie jak funkcje <strong>get<\/strong>, funkcje <strong>push<\/strong> Firebase&#8217;a obs\u0142uguj\u0105 priorytet.<br><strong>ETag<\/strong> nie jest dost\u0119pny po push, chyba \u017ce odczytamy <strong>ETag<\/strong> dla tego nowo do\u0142\u0105czonego unikalnego klucza p\u00f3\u017aniej, za pomoc\u0105 funkcji <strong>Firebase.getETag<\/strong>.<br><strong>Timestamp<\/strong> serwera mo\u017ce by\u0107 do\u0142\u0105czony do bazy danych za pomoc\u0105 <strong>Firebase.pushTimestamp<\/strong>.<br>Unikalny klucz timestampa mo\u017ce by\u0107 okre\u015blony po jego do\u0142\u0105czeniu.<br>Poni\u017cszy przyk\u0142ad pokazuje, jak doda\u0107 nowe dane (u\u017cywaj\u0105c obiektu FirebaseJson) do &#8222;\/test\/append.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\n\nFirebaseJson json;\nFirebaseJson json2;\n\njson2.set(&quot;child_of_002&quot;, 123.456);\njson.set(&quot;parent_001&quot;, &quot;parent 001 text&quot;);\njson.set(&quot;parent 002&quot;, json2);\n\nif (Firebase.pushJSON(fbdo, &quot;\/test\/append&quot;, json)) {\n\n  Serial.println(fbdo.dataPath());\n\n  Serial.println(fbdo.pushName());\n\n  Serial.println(fbdo.dataPath() + &quot;\/&quot;+ fbdo.pushName());\n\n} else {\n  Serial.println(fbdo.errorReason());\n}\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Do\u0142\u0105czanie danych Aby doda\u0107 nowe dane do okre\u015blonego w\u0119z\u0142a w Firebase RTDB, u\u017cyj funkcji push.W\u015br\u00f3d funkcji dost\u0119pne s\u0105: push, pushInt, pushFloat, pushDouble, pushBool, pushString, pushJSON, pushArray, pushBlob oraz pushFile.Funkcje te&#8230;<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":3205,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-4483","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages\/4483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/comments?post=4483"}],"version-history":[{"count":4,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages\/4483\/revisions"}],"predecessor-version":[{"id":4498,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages\/4483\/revisions\/4498"}],"up":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages\/3205"}],"wp:attachment":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/media?parent=4483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}