Hi Sarah,
You're certainly on the right track - unfortunately it is not
currently possible to update the priority of an object without setting
the entire object again. This is a feature request we are actively
tracking and are working on. I'll let you know as soon as it is
available!
In the interim, would it be possible to share a bit more about why you
want to update the priority of the parent object when a child is
added? There might be other ways to structure your data so we can
achieve the end-goal. For instance, we could create a separate object
called "priorities" at the top-level which only contains a list of
object names with their priorities:
{
"priorities": {
"parent1": { ".priority": 2, "is": true},
"parent2": { ".priority": 1, "is": true}
},
"parent1": {
"foo": "foo_val"
},
"parent2": {
"bar": "bar_val"
}
}
When you add a child to, say parent1, you can update the priorities
object with a PUT to /priorities/parent1. Then, when you need to read
the data in order, first enumerate /priorities then fetch each parent
in the priority order.
Hope this helps!
-Anant
On Sun, Dec 30, 2012 at 6:57 PM, Sarah Reichelt
<
sarah.r...@gmail.com> wrote:
> Thanks for the speedy reply Anant.
>
> I see now that this is the way to do it, but I can't work out exactly how to
> :-(
>
> What I am actually trying to do is to update the priority of an object when
> a new child is added to it.
> I add the child without any problem, but once that has worked, I want to set
> the .priority property of the parent object.
>
> I am using PHP as this will be running on a server without node.js
> installed.
>
> So here is how I add the child - I worked out that I had to send the object
> as a string version of JSON object.
>
> $url = '
https://my_db.firebaseio.com/' . $parentID . '/comms/' . $timeStamp
> . '.json';
> $fields = '{ ".priority" : ' . $timeStamp . ',
> "name" : "' . $name . '",
> "comment" : "' . $comment . '" }' ;
> $result = doPut($url, $fields);
>
> Then when I want to update the .priority of the parent object, I see that I
> need to PUT the data to this URL:
>
> $url = '
https://my_db.firebaseio.com/' . $parentID . '/.priority.json';
>
> But what exactly do I PUT?
> I don't have a key:value pair - I just have a value which is a UNIX
> timestamp stored in the $timeStamp variable.
>
> I have tried putting:
> $timeStamp; // replaces the contents of the parent object with the time
> stamp
> '"' . $timeStamp . '"'; // replaces the contents of the parent object with
> the time stamp
> '{' . $timeStamp . '}'; // does nothing
>
>
> I am sure I am on the right track, I am just missing something...
>
> Cheers,
> Sarah