我正在使用Firebase,Backend-as-a-Service,用于我的网站应用程序,由AngularJS编程.
@H_301_18@我想使用db查询来获取记录,例如:WHERE name ==’The Legend Of Korra’
{ "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's 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 } } }
我正在使用的代码使这个工作:
$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; };
我想在不使用$firebaseArray和forEach的情况下完成这项工作.我该怎么做?
就像这样:
var seriesRef = new Firebase('http://<<firebaseapp>>.firebaseio.com/series'); var seriesObject = $firebaSEObject(seriesRef.query({ name: seriesName }));