使用 R 将数组写入 firebase
Using R to write arrays to firebase
您好,我有一个脚本可以生成一些数据并将其存储在数据框中。我现在想将数据帧作为数组保存到 fire-base,但是我有一个我无法解决的奇怪问题。不是将数据作为数组直接存储在文件系统的根目录中,即 parent/child/0 parent/child/1,而是将数据存储为 /parent/child/some-random-chars/0、/parent/child/some-random-chars/1
要重现的代码。
library(httr)
library(jsonlite)
POST("https://xxxxxxx.firebaseio.com/parent/child.json", body = toJSON(mtcars, pretty = TRUE))
P.S:随机字符串看起来像这样“-HfyD-w0LsgwvGgD8ukQ”
最终我发现这是因为我使用的是 POST 而不是 PUT。当您使用 POST 时,firebase 会生成推送 ID 并将它们添加到您的数据中。当您使用 PUT 时,它会将您的数据直接存储在指定的端点。
您好,我有一个脚本可以生成一些数据并将其存储在数据框中。我现在想将数据帧作为数组保存到 fire-base,但是我有一个我无法解决的奇怪问题。不是将数据作为数组直接存储在文件系统的根目录中,即 parent/child/0 parent/child/1,而是将数据存储为 /parent/child/some-random-chars/0、/parent/child/some-random-chars/1
要重现的代码。
library(httr)
library(jsonlite)
POST("https://xxxxxxx.firebaseio.com/parent/child.json", body = toJSON(mtcars, pretty = TRUE))
P.S:随机字符串看起来像这样“-HfyD-w0LsgwvGgD8ukQ”
最终我发现这是因为我使用的是 POST 而不是 PUT。当您使用 POST 时,firebase 会生成推送 ID 并将它们添加到您的数据中。当您使用 PUT 时,它会将您的数据直接存储在指定的端点。