Skip to content

Instantly share code, notes, and snippets.

@Epotignano
Created February 11, 2015 12:22
Show Gist options
  • Save Epotignano/ff93c3061fc2a6c9cb85 to your computer and use it in GitHub Desktop.
Save Epotignano/ff93c3061fc2a6c9cb85 to your computer and use it in GitHub Desktop.
serv.match = function(collection,propertyToMatch, query) {
var sync;
/*if(propertyToMatch.indexOf(".") != -1) {
var properties = propertyToMatch.split(".");
sync = $firebase(ref.child(collection).child(properties[0]).child(properties[1]).orderByChild(properties[1]).startAt(query).endAt(query+"~"));
} else {*/
sync = $firebase(ref.child(collection).orderByChild(propertyToMatch).startAt(query).endAt(query+"~"));
// }
var matchPromise = $q.defer();
var record = sync.$asObject();
record.$loaded().then(function(data) {
matchPromise.resolve(data);
});
return matchPromise.promise;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment