diff --git a/.gitignore b/.gitignore deleted file mode 100755 index 64d8586..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -keys -*.swp diff --git a/README.md b/README.md index c99e627..a994d50 100755 --- a/README.md +++ b/README.md @@ -60,7 +60,12 @@ $scope.objects.update(object); If you would only like to fetch objects with a certain condition, use `where`. ``` javascript -$scope.objects = pang.Collection(ParseTable).where({'isAwesome', true}).build(); +$scope.objects = pang.Collection(ParseTable).where('isAwesome', true).build(); +``` + +To fetch objects if they exist, use `exist`. +``` javascript +$scope.objects = pang.Collection(ParseTable).exists('hasAwesomePower', true).build(); ``` Sort the objects with `order`. diff --git a/app.js b/app.js deleted file mode 100755 index 2af7668..0000000 --- a/app.js +++ /dev/null @@ -1,57 +0,0 @@ -//the main app -var pangTest = angular.module('pangTest', ['ngResource', 'pang']) - -//the controller for the tests -.controller('PangTestCtrl', function($scope, pang) { - - //initialize the Pang Object - pang.initialize('GqBCNGLwUKpoq8CW3zhV8Q2bDovMsHsPPUaYYW8F','19QUZxLzX8bZSZ4IGpOkfSWvQUGdnU38e4Dih5Pm'); - - //create the snippet table and populate - $scope.objects = pang.Collection('Snippet').order('name').setAutoSync(false).build(); - - //handle login/logout info - $scope.loggedIn = Parse.User.current() ? true : false; - $scope.login = function() { - pang.User.logIn('testusername', '13661'); - $scope.loggedIn = true; - } - $scope.logout = function() { - pang.User.logOut(); - $scope.loggedIn = false; - } - - //delete an object - $scope.deleteObject = function($index) { - if($scope.objects[$index].canWrite == true) { - $scope.objects.delete($index); - } else { - alert('You do not have permission to write!'); - } - } - - //add a new object - $scope.addObject = function() { - - if(Parse.User.current()) { - var parseACL = new Parse.ACL(Parse.User.current()); - parseACL.setPublicReadAccess($scope.pubReadChecked == true); - parseACL.setPublicWriteAccess($scope.pubWriteChecked == true); - $scope.objects.add({name: $scope.inputText, ACL: parseACL}); - } else { - alert('You do not have permission to write!'); - } - } - - //update an object - $scope.updateObject = function($index) { - if($scope.objects[$index].canWrite == true) { - var object = $scope.objects[$index]; - object.name = $scope.inputText; - $scope.objects.update(object); - } else { - alert('You do not have permission to write!'); - } - } - -}); diff --git a/index.html b/index.html deleted file mode 100755 index 95076a0..0000000 --- a/index.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - Tests for Pang - - - - - - - - - - - - - - - - - - -

Tests for Pang

-
-

No one logged in

- -
-
-

testusername logged in

- -
-
- - - - - - - - - - - - - - - -
Objects:
{{object.name}} - - -
- - -
-
- - Public Read - Public Write -
- - diff --git a/pang.js b/pang.js index 76fd669..2d990aa 100755 --- a/pang.js +++ b/pang.js @@ -433,6 +433,19 @@ angular.module('pang', []).factory('pang', function($rootScope) { } // pangCollection.where() + /*************************************************************** + * + * pangCollection.exists() + * + * Add the attributes to the list of matchs to add to the query. + * + ***************************************************************/ + pangCollection.exists = function(key, existence) { + pangCollection.exists[key] = existence != null ? existence : true; + return pangCollection; + } // pangCollection.exists() + + /*************************************************************** * * pangCollection.order() @@ -477,6 +490,19 @@ angular.module('pang', []).factory('pang', function($rootScope) { query.equalTo(match, pangCollection.queryMatches[match]); } + //add all the needed existences to the query + for(key in pangCollection.exists) { + + //ascending + if(pangCollection.exists[key] == true) { + query.exists(key); + + //descending + } else { + query.doesNotExist(key); + } + } + //add sorting to the query which has been specified by the user with 'order' for(key in pangCollection.orders) {