@@ -1440,6 +1440,17 @@ var pluginManager = function pluginManager() {
1440
1440
return ;
1441
1441
}
1442
1442
return function ( err , res ) {
1443
+ if ( res ) {
1444
+ if ( ! res . result ) {
1445
+ res . result = { } ;
1446
+ }
1447
+ if ( ! res . result . ok ) {
1448
+ res . result . ok = ! err ;
1449
+ }
1450
+ if ( ! res . result . nModified ) {
1451
+ res . result . nModified = res . modifiedCount || 0 ;
1452
+ }
1453
+ }
1443
1454
if ( err ) {
1444
1455
if ( retry && err . code === 11000 ) {
1445
1456
if ( typeof retry === "function" ) {
@@ -1740,10 +1751,17 @@ var pluginManager = function pluginManager() {
1740
1751
logDbRead . d ( "aggregate " + collection + " %j %j" + at , query , options ) ;
1741
1752
logDbRead . d ( "From connection %j" , countlyDb . _cly_debug ) ;
1742
1753
var cursor = this . _aggregate ( query , options ) ;
1754
+ cursor . _count = cursor . count ;
1755
+ cursor . count = function ( ) {
1756
+ return ob . countDocuments . apply ( ob , arguments ) ;
1757
+ } ;
1743
1758
cursor . _toArray = cursor . toArray ;
1744
1759
cursor . toArray = function ( cb ) {
1745
1760
return handlePromiseErrors ( cursor . _toArray ( logForReads ( cb , e , copyArguments ( args , "aggregate" ) ) ) , e , copyArguments ( arguments , "aggregate" ) ) ;
1746
1761
} ;
1762
+ cursor . isClosed = function ( ) {
1763
+ return cursor . closed || cursor . killed ;
1764
+ } ;
1747
1765
if ( typeof callback === "function" ) {
1748
1766
return cursor . toArray ( callback ) ;
1749
1767
}
@@ -1782,10 +1800,17 @@ var pluginManager = function pluginManager() {
1782
1800
logDbRead . d ( "find " + collection + " %j %j" + at , query , options ) ;
1783
1801
logDbRead . d ( "From connection %j" , countlyDb . _cly_debug ) ;
1784
1802
var cursor = this . _find ( query , options ) ;
1803
+ cursor . _count = cursor . count ;
1804
+ cursor . count = function ( ) {
1805
+ return ob . countDocuments . apply ( ob , arguments ) ;
1806
+ } ;
1785
1807
cursor . _toArray = cursor . toArray ;
1786
1808
cursor . toArray = function ( callback ) {
1787
1809
return handlePromiseErrors ( cursor . _toArray ( logForReads ( callback , e , copyArguments ( args , "find" ) ) ) , e , copyArguments ( arguments , "find" ) ) ;
1788
1810
} ;
1811
+ cursor . isClosed = function ( ) {
1812
+ return cursor . closed || cursor . killed ;
1813
+ } ;
1789
1814
return cursor ;
1790
1815
} ;
1791
1816
@@ -1841,6 +1866,20 @@ var pluginManager = function pluginManager() {
1841
1866
return ob . findOneAndDelete ( query , options , callback ) ;
1842
1867
} ;
1843
1868
1869
+ ob . _drop = ob . drop ;
1870
+ ob . drop = function ( ) {
1871
+ if ( ! arguments . length ) {
1872
+ return ob . _drop ( ) . catch ( function ( ex ) {
1873
+ if ( ex . code !== 26 ) {
1874
+ throw ex ;
1875
+ }
1876
+ } ) ;
1877
+ }
1878
+ else {
1879
+ return ob . _drop . apply ( ob , arguments ) ;
1880
+ }
1881
+ } ;
1882
+
1844
1883
1845
1884
countlyDb . _collection_cache [ collection ] = ob ;
1846
1885
0 commit comments