firebase-ruby icon indicating copy to clipboard operation
firebase-ruby copied to clipboard

Push multiple objects at once

Open aaossa opened this issue 7 years ago • 1 comments

Hi, I'm trying to push multiple objects using one requests but I couldn't fin a way to do this using this gem. See this SO question for reference, it's in JS but the problem is the same. It looks like it is possible to push multiple objects at once using JS, so I think should be possible using this gem.

What I want is to start from something like this:

|> container
  |> -Km4sgiVoeXVx4ZLKe9a # parent_id
    |> div

Then I push multiple objects. Something like firebase.push("container/#{parent_id}/div", array), with an array like [{ a_key: A}, { a_key: B}, { a_key: C}] (currently this assigns the array index as ID).

Desired output:

|> container
  |> -Km4sgiVoeXVx4ZLKe9a # parent_id
    |> div
      |> -Km8IlUaZfgrrUB5tXQt # <= This is one of the objects I want to create
        |> a_key: A
      |> -Km8NBTEsaM1ElVBHNfH # <= Another created object
        |> a_key: B
      |>  -Km8NDYxTc0ldb_XV7Ti # <= Another created object
        |> a_key: C

Can I accomplish this using this gem? Is there another way to do this with just one request? Thanks!

aaossa avatar Jun 09 '17 07:06 aaossa

It may not be possible. Reading https://firebase.google.com/docs/reference/rest/database/ doesn't give an indication that they allow pushing multiple objects via REST. However, if you can generate an equivalent cURL request that does what you want, we can probably get this library to do the right thing.

vincentwoo avatar Jun 10 '17 20:06 vincentwoo