1
1
/*
2
2
* Parse + React
3
- * v0.4.1
3
+ * v0.4.2
4
4
*/
5
5
( function ( f ) { if ( typeof exports === "object" && typeof module !== "undefined" ) { module . exports = f ( ) } else if ( typeof define === "function" && define . amd ) { define ( [ ] , f ) } else { var g ; if ( typeof window !== "undefined" ) { g = window } else if ( typeof global !== "undefined" ) { g = global } else if ( typeof self !== "undefined" ) { g = self } else { g = this } g . ParseReact = f ( ) } } ) ( function ( ) { var define , module , exports ; return ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; var f = new Error ( "Cannot find module '" + o + "'" ) ; throw f . code = "MODULE_NOT_FOUND" , f } var l = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( l . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ?n :e ) } , l , l . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( _dereq_ , module , exports ) {
6
6
/*
@@ -1606,6 +1606,7 @@ module.exports = ObjectStore;
1606
1606
*/
1607
1607
1608
1608
var flatten = _dereq_ ( './flatten' ) ;
1609
+ var Id = _dereq_ ( './Id' ) ;
1609
1610
var LocalSubscriptions = _dereq_ ( './LocalSubscriptions' ) ;
1610
1611
var Parse = _dereq_ ( './StubParse' ) ;
1611
1612
var SubscriptionManager = _dereq_ ( './SubscriptionManager' ) ;
@@ -1663,6 +1664,8 @@ var patches = {
1663
1664
return promise ;
1664
1665
} } ;
1665
1666
1667
+ var pointerMethods = [ 'equalTo' , 'notEqualTo' , 'containedIn' , 'notContainedIn' ] ;
1668
+
1666
1669
var ParsePatches = {
1667
1670
applyPatches : function applyPatches ( ) {
1668
1671
if ( ! Parse . Object . prototype . toPlainObject ) {
@@ -1674,6 +1677,32 @@ var ParsePatches = {
1674
1677
if ( ! Parse . Query . prototype . observeOne ) {
1675
1678
Parse . Query . prototype . observeOne = patches . observeOne ;
1676
1679
}
1680
+ pointerMethods . forEach ( function ( method ) {
1681
+ var old = Parse . Query . prototype [ method ] ;
1682
+ Parse . Query . prototype [ method ] = function ( attr , value ) {
1683
+ var patchedValue = value ;
1684
+ if ( Array . isArray ( value ) ) {
1685
+ patchedValue = value . map ( function ( v ) {
1686
+ if ( v && v . id && v . id instanceof Id ) {
1687
+ return {
1688
+ __type : 'Pointer' ,
1689
+ className : v . id . className ,
1690
+ objectId : v . id . objectId
1691
+ } ;
1692
+ }
1693
+ return v ;
1694
+ } ) ;
1695
+ } else if ( value && value . id && value . id instanceof Id ) {
1696
+ patchedValue = {
1697
+ __type : 'Pointer' ,
1698
+ className : value . id . className ,
1699
+ objectId : value . id . objectId
1700
+ } ;
1701
+ }
1702
+
1703
+ return old . call ( this , attr , patchedValue ) ;
1704
+ } ;
1705
+ } ) ;
1677
1706
Parse . User . prototype . signUp = patches . signUp ;
1678
1707
Parse . User . prototype . logIn = patches . logIn ;
1679
1708
Parse . User . prototype . _linkWith = patches . _linkWith ;
@@ -1683,7 +1712,7 @@ var ParsePatches = {
1683
1712
1684
1713
module . exports = ParsePatches ;
1685
1714
1686
- } , { "./LocalSubscriptions" :5 , "./StubParse" :13 , "./SubscriptionManager" :15 , "./flatten" :18 } ] , 12 :[ function ( _dereq_ , module , exports ) {
1715
+ } , { "./Id" : 4 , "./ LocalSubscriptions" :5 , "./StubParse" :13 , "./SubscriptionManager" :15 , "./flatten" :18 } ] , 12 :[ function ( _dereq_ , module , exports ) {
1687
1716
( function ( process ) {
1688
1717
/*
1689
1718
* Copyright (c) 2015, Parse, LLC. All rights reserved.
@@ -1969,10 +1998,26 @@ function matchesKeyConstraints(object, key, constraints) {
1969
1998
return false ;
1970
1999
}
1971
2000
break ;
2001
+ case '$nearSphere' :
2002
+ var distance = compareTo . radiansTo ( object [ key ] ) ;
2003
+ var max = constraints . $maxDistance || Infinity ;
2004
+ return distance <= max ;
2005
+ case '$within' :
2006
+ var southWest = compareTo . $box [ 0 ] ;
2007
+ var northEast = compareTo . $box [ 1 ] ;
2008
+ if ( southWest . latitude > northEast . latitude || southWest . longitude > northEast . longitude ) {
2009
+ // Invalid box, crosses the date line
2010
+ return false ;
2011
+ }
2012
+ return object [ key ] . latitude > southWest . latitude && object [ key ] . latitude < northEast . latitude && object [ key ] . longitude > southWest . longitude && object [ key ] . longitude < northEast . longitude ;
1972
2013
case '$options' :
1973
2014
// Not a query type, but a way to add options to $regex. Ignore and
1974
2015
// avoid the default
1975
2016
break ;
2017
+ case '$maxDistance' :
2018
+ // Not a query type, but a way to add a cap to $nearSphere. Ignore and
2019
+ // avoid the default
2020
+ break ;
1976
2021
case '$select' :
1977
2022
return false ;
1978
2023
case '$dontSelect' :
0 commit comments