Restrictive Queries with Firebase
How do I make an restrictive queries with firebase?
What is a restrictive queries with firebase? How do you make a restrictive queries with firebase? This script and codes were developed by David on 14 November 2022, Monday.
Restrictive Queries with Firebase - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Restrictive Queries with Firebase</title>
</head>
<body> <div data-ng-app="firelimit"> <div data-ng-controller="LimitCtrl"></div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js"></script>
<script src="https://cdn.firebase.com/js/client/1.0.6/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/0.7.1/angularfire.min.js"></script> <script src="js/index.js"></script>
</body>
</html>
Restrictive Queries with Firebase - Script Codes JS Codes
/*global Firebase*/
(function (angular) { var app = angular.module('firelimit', ['firebase']); // Store the firebase url as a constant app.constant('FBURL', 'https://brilliant-fire-2753.firebaseio.com/messages'); app.service('MessagesRef', function ($firebase, FBURL) { return { create: function () { return new Firebase(FBURL); } }; }); app.service('MessagesService', function(MessagesRef, $q) { var messagesRef = MessagesRef.create(); return { childAdded: function(cb) { messagesRef.on('child_added', function(snapshot, prev) { //console.log(prev); cb.call(this, snapshot); }); }, getMostRecent: function(limit, startAt) { var deferred = $q.defer(); messagesRef.limit(limit ? limit : 10).once('value', function(snapshot) { deferred.resolve(snapshot.val()); }); return deferred.promise; }, getBetweenItems: function(startAt, endAt) { var deferred = $q.defer(); messagesRef.startAt(null, startAt).endAt(null, endAt).once('value', function(snapshot) { console.log(snapshot.val()); deferred.resolve(snapshot.val()); }); return deferred.promise; }, page: function(lastItem, items) { var deferred = $q.defer(); messagesRef.startAt(null, lastItem).limit(items).once('value', function(snapshot) { console.log(snapshot.val()); deferred.resolve(snapshot.val()); }); return deferred.promise; } }; }); app.controller('LimitCtrl', ['$scope', 'MessagesService', function ($scope, MessagesService) { $scope.messages = []; MessagesService.getMostRecent(5); //MessagesService.getBetweenItems('-JIQWA3ZPdhrYE-2Kvh_', null); //MessagesService.page('-JIQWA3ZPdhrYE-2Kvh_', 10); /*MessagesService.childAdded(function(promise) { //console.log(promise.val()); });*/ } ]);
})(window.angular);
Developer | David |
Username | david-east |
Uploaded | November 14, 2022 |
Rating | 3 |
Size | 2,083 Kb |
Views | 24,288 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Flat UI Login Form | 3,079 Kb |
Mobile Disabled Animation | 2,985 Kb |
A Pen by David | 1,823 Kb |
HTML5 Geolocation | 1,456 Kb |
Polaroid Fade-in | 2,986 Kb |
IPhone Targeting | 2,073 Kb |
LESS - Nesting | 2,326 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Social Profiles | Lachlanjc | 1,939 Kb |
Android Play Store With Slick Carousel | -J0hn- | 4,982 Kb |
Simple, flat contact form | Zeaklous | 2,719 Kb |
Testing Code Pen | Jduprey | 1,468 Kb |
Login-ng-modal | Heedoo | 3,566 Kb |
Countdown Timer | Massiebn | 3,001 Kb |
Opening Reveal Modal On Document Ready | Winghouchan | 1,787 Kb |
Sony Xperia Z3 Flat MockUp | Dapinitial | 4,379 Kb |
CSS Heart Loaders | Nourabusoud | 2,161 Kb |
Animate a paper plane along an SVG path, looking ahead | PotatoDie | 3,734 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!