I am using Firebase, Backend-as-a-Service, for my web application, programming AngularJS.
I want to use db queries to retrieve records, for example: WHERE name == 'The Legend Of Korra'
I have an array of TV shows on a Firebase server, JSON CODE :
{ "series" : { "-JkqSvwyDw5F9DvGUu6b" : { "createdAt" : 1426842959884, "creators" : "Michael Dante DiMartino,Bryan Konietzko", "description" : "The series follows the adventures of protagonist twelve-year-old Aang and his friends, who must bring peace and unity to the world by ending the Fire Lord war against the other three nations.", "episode_reset" : true, "genres" : "Action,Adventure,Fantasy,Comedy-drama", "keywords" : "avatar,the last airbender", "name" : "Avatar: The Last Airbender", "official_website" : "http://nicktoons.nick.com/shows/avatar", "publish_date" : "2005-02-21", "updatedAt" : 1426843055127 } } }
The code I'm using now to do this:
$scope.isSeriesValid = function(seriesName) { var seriesRef = new Firebase('http://<<firebaseapp>>.firebaseio.com/series'); var seriesCollection = $firebaseArray(seriesRef); seriesCollection.$loaded(function() { angular.forEach(seriesCollection, function(seriesObject, index) { if(seriesObject.name == seriesName) return true; }); }); return false; };
I want to do this without using $firebaseArray and forEach . How can I do it?
Just something like this:
var seriesRef = new Firebase('http://<<firebaseapp>>.firebaseio.com/series'); var seriesObject = $firebaseObject(seriesRef.query({ name: seriesName }));
angularjs firebase angularfire
Matan yedayev
source share