FAQ
Hi guys,

I am adding data in the following way in my application

return $firebase(ref).$add(data).then(
         function (ref) {
           var id = ref.name();
           return id;
         },
         function (err) {
           console.error('ERROR:', err);
           return null;
         }
       );


the 'data' i am adding looks like the following

{
date: Firebase.ServerValue.TIMESTAMP,
status: 'active',
name: $scope.name,
email: $scope.email
}

im trying to do a where statement to get all entries where the status is
'active', some are set to 'disabled'. The statment im doing looks like the
following:

new Firebase(URL)
       .startAt('active')
       .endAt('active')
       .once('value', function(snap){
         console.log(snap.val());
       });

snap.val() is returning NULL.

Please can someone explain why and how to fix it?

Thanks


--
You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
To post to this group, send email to firebase-angular@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/8e9fc2c3-3acb-4302-8c26-7f2d5c27301a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Michael Wulf at Jul 25, 2014 at 6:11 pm
    Peter,

    To make this work with queries, you need to utilize priorities. Start by
    creating your records using setWithPriority:

    ref.setWithPriority({
       date: Firebase.ServerValue.TIMESTAMP,
       status: 'active',
       name: $scope.name,
       email: $scope.email
    }, 'active');

    Now your query above will work. Alternately, if records are normally
    fetched by active or inactive, you can simply store them that way in
    Firebase:

    records/active/...
    records/inactive/...

    new Firebase(URL+'/active').once('value', ...);

    If you need more dynamic ways to fetch them, you can create indices
    <https://www.firebase.com/docs/web/guide/structuring-data.html#section-indices>
    and use those to refer to more dynamic lists.

    Cheers,


    On Fri, Jul 25, 2014 at 6:11 AM, peter ingram wrote:

    Hi guys,

    I am adding data in the following way in my application

    return $firebase(ref).$add(data).then(
    function (ref) {
    var id = ref.name();
    return id;
    },
    function (err) {
    console.error('ERROR:', err);
    return null;
    }
    );


    the 'data' i am adding looks like the following

    {
    date: Firebase.ServerValue.TIMESTAMP,
    status: 'active',
    name: $scope.name,
    email: $scope.email
    }

    im trying to do a where statement to get all entries where the status is
    'active', some are set to 'disabled'. The statment im doing looks like the
    following:

    new Firebase(URL)
    .startAt('active')
    .endAt('active')
    .once('value', function(snap){
    console.log(snap.val());
    });

    snap.val() is returning NULL.

    Please can someone explain why and how to fix it?

    Thanks


    --
    You received this message because you are subscribed to the Google Groups
    "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/firebase-angular/8e9fc2c3-3acb-4302-8c26-7f2d5c27301a%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/8e9fc2c3-3acb-4302-8c26-7f2d5c27301a%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/CAFHX4%3Do%2BsrGk1KM3%2B0hMm2np9J0NmvL6FJyN5QHLf-e3DCp9Bg%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupfirebase-angular @
postedJul 25, '14 at 2:38p
activeJul 25, '14 at 6:11p
posts2
users2

2 users in discussion

Peter ingram: 1 post Michael Wulf: 1 post

People

Translate

site design / logo © 2021 Grokbase