diff --git a/bower.json b/bower.json index e04f8ee..ea871ec 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "kendo-pouchdb", "main": "kendo-pouchdb.js", - "version": "0.0.6", + "version": "0.0.7", "description": "Kendo UI adapter for PouchDB", "homepage": "https://github.com/terikon/kendo-pouchdb", diff --git a/dist/kendo-pouchdb.amd.min.js b/dist/kendo-pouchdb.amd.min.js index cb9c40f..6c3f949 100644 --- a/dist/kendo-pouchdb.amd.min.js +++ b/dist/kendo-pouchdb.amd.min.js @@ -1,2 +1,2 @@ -/* kendo-pouchdb.amd v0.0.6 15-05-2015 (C) 2015 Terikon Software */ +/* kendo-pouchdb.amd v0.0.7 15-05-2015 (C) 2015 Terikon Software */ define(["kendo","kendo-pouchdb"],function(a){"use strict";return a}); \ No newline at end of file diff --git a/dist/kendo-pouchdb.min.js b/dist/kendo-pouchdb.min.js index 8e81355..9b1870c 100644 --- a/dist/kendo-pouchdb.min.js +++ b/dist/kendo-pouchdb.min.js @@ -1,4 +1,4 @@ -/* kendo-pouchdb v0.0.6 15-05-2015 (C) 2015 Terikon Software */ +/* kendo-pouchdb v0.0.7 15-05-2015 (C) 2015 Terikon Software */ -!function(a,b){b(["PouchDB","pouchCollate"],a)}(function(a,b){if(!a)throw new Error('Please include "pouchdb.js" before kendo-pouchdb');if(!b)throw new Error('Please include "pouchdb-collate.js" before kendo-pouchdb');return function(c){var d=kendo.data.RemoteTransport.extend({init:function(b){var c=b&&b.pouchdb?b.pouchdb:{},d=c.db,e=c.idField,f=c.fieldViews||{};if(!d)throw new Error('The "db" option must be set.');if(!(d instanceof a))throw new Error('The "db" option must be a PouchDB object.');if(this.db=d,!e)throw new Error('The "idField" option must be set.');this.idField=e,this.fieldViews=f,this.dataSource=b.data.dataSource,kendo.data.RemoteTransport.fn.init.call(this,b)},push:function(a){var b=this,d=this.db.changes({since:"now",live:!0,include_docs:!0});d.on("change",function(d){var e,f=b._crudPromises.slice(),g=d.doc;c.when.apply(c,f).then(function(){if(d.deleted)a.pushDestroy(g);else if(e=b.dataSource.get(g._id),void 0!==e){if(g._rev===e._rev)return;a.pushUpdate(g)}else b.dataSource.pageSize()||a.pushCreate(g)})}),d.on("error",function(a){})},read:function(b){var d,e=this,f=this._getFieldViewAndDirForSort(b.data.sort),g=f.fieldView?e.db.query.bind(e.db,f.fieldView):e.db.allDocs,h=b.data.pageSize,i=b.data.page,j=function(){return g!==e.db.allDocs?a.utils.Promise.resolve(0):e.db.allDocs({startkey:"_design/",endkey:"_design￿"}).then(function(a){return a.rows.length})};e._validateFilter(b.data.filter,b.data.sort);var k=this._getFilterQueryOptions(b.data.filter);void 0!==h?(void 0===i&&(i=1),d=h*(i-1)):d=void 0;var l=c.extend({include_docs:!0,descending:f.descending,skip:d,limit:h},k);j().then(function(a){return g.call(e.db,l).then(function(c){c.total_rows-=a,b.success(c)})})["catch"](function(a){b.error([],a.status,a)})},_crudPromises:[],_crud:function(a,b,d,e){var f=this,g=new c.Deferred,h=g.promise(),i=function(){g.resolve();var a=f._crudPromises.indexOf(h);f._crudPromises.splice(a,1)};this._crudPromises.push(h),e.call(this,b).then(function(a){b._rev=a.rev,d.success(b),i()})["catch"](function(b){409===b.status&&console.log(kendo.format("kendo-pouchdb: conflict occured for {0}: {1}",a,b)),d.error([],b.status,b),i()})},create:function(a){var c=a.data;c._id=b.toIndexableString(c[this.idField]),this._crud("create",c,a,function(a){return this.db.put(a)})},update:function(a){var b=a.data;this._crud("update",b,a,function(a){return this.db.put(a)})},destroy:function(a){var b=a.data;this._crud("destroy",b,a,function(a){return this.db.remove(a)})},_getFieldViewAndDirForSort:function(a){var b,c,d;if(!a||0===a.length)return{descending:!1};if(a.length>1)throw new Error("Sorting by multiple fields is not supported by kendo-pouchdb");if(b=a[0].field,c=a[0].dir&&"desc"===a[0].dir,"_id"===b||b===this.idField)return{descending:c};if(d=this.fieldViews[b],!d)throw new Error("No PouchDB view provided for sorting by '"+b+"'");return{fieldView:d,descending:c}},_validateFilter:function(a,b){if(a&&0!==a.filters.length){var c=a.filters;if(c.length>1)throw new Error("array of filters is currently not supported");var d=c[0].field,e=b&&b.length>0?b[0].field:this.idField;if(e!=d)throw new Error("filtering by field and then sorting by another field is not supported")}},_getFilterQueryOptions:function(a){if(!a||0===a.filters.length)return void 0;var c=a.filters[0].field,d=a.filters[0].operator,e=c===this.idField||"_id"===c?b.toIndexableString(a.filters[0].value):a.filters[0].value;if(["neq","gt"].indexOf(d)>=0)throw new Error(kendo.format("{0} operator is currently not supported for field '{1}'",d,c));switch(d){case"eq":return{key:e};case"lt":return{endkey:e,inclusive_end:!1};case"lte":return{endkey:e,inclusive_end:!0};case"gte":return{startkey:e}}return void 0}}),e={type:"json",data:function(a){if(a.rows){var b=c.map(a.rows,function(a){return 0!==a.doc._id.indexOf("_design/")?a.doc:void 0});return b}return a},total:function(a){return a.total_rows}};c.extend(!0,kendo.data,{schemas:{pouchdb:e},transports:{pouchdb:d}});var f=kendo.data.DataSource.extend({init:function(a){if(a&&a.type&&"pouchdb"===a.type){var b;if(a=c.extend(!0,{},a),this._ispouchdb=!0,a.schema&&a.schema.model&&a.schema.model.fn&&a.schema.model.fn instanceof kendo.data.Model){if(b=a.schema.model,"_id"!==b.idField)throw new Error('The Model\'s id option should be "_id"')}else if(a=c.extend(!0,{schema:{model:{id:"_id"}}},a),"_id"!==a.schema.model.id)throw new Error('The model.id option should not be provided or should be "_id"');if(a.serverPaging=void 0===a.serverPaging?!0:a.serverPaging,a.serverFiltering=void 0===a.serverFiltering?!0:a.serverFiltering,a.serverSorting=void 0===a.serverSorting?!0:a.serverSorting,a.serverGrouping=void 0===a.serverGrouping?!0:a.serverGrouping,a.serverAggregates=void 0===a.serverAggregates?!0:a.serverAggregates,a.data)throw new Error("For DataSource of type pouchdb data option should not be provided");a.data={dataSource:this}}kendo.data.DataSource.fn.init.apply(this,arguments)},getByModelId:function(a){return this._ispouchdb?kendo.data.DataSource.fn.get.call(this,b.toIndexableString(a)):kendo.data.DataSource.fn.get.apply(this,arguments)}});f.create=kendo.data.DataSource.create,kendo.data.PouchableDataSource=f}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(a,b){b(window.PouchDB,window.pouchCollate)}); +!function(a,b){b(["PouchDB","pouchCollate"],a)}(function(a,b){if(!a)throw new Error('Please include "pouchdb.js" before kendo-pouchdb');if(!b)throw new Error('Please include "pouchdb-collate.js" before kendo-pouchdb');return function(c){var d=kendo.data.RemoteTransport.extend({init:function(b){var c=b&&b.pouchdb?b.pouchdb:{},d=c.db,e=c.idField,f=c.fieldViews||{};if(!d)throw new Error('The "db" option must be set.');if(!(d instanceof a))throw new Error('The "db" option must be a PouchDB object.');if(this.db=d,!e)throw new Error('The "idField" option must be set.');this.idField=e,this.fieldViews=f,this.dataSource=b.data.dataSource,kendo.data.RemoteTransport.fn.init.call(this,b)},push:function(a){var b=this,d=this.db.changes({since:"now",live:!0,include_docs:!0});d.on("change",function(d){var e,f=b._crudPromises.slice(),g=d.doc;c.when.apply(c,f).then(function(){if(d.deleted)a.pushDestroy(g);else if(e=b.dataSource.get(g._id),void 0!==e){if(g._rev===e._rev)return;a.pushUpdate(g)}else b.dataSource.pageSize()||a.pushCreate(g)})}),d.on("error",function(a){})},read:function(b){var d,e,f,g,h=this,i=this._getFieldViewAndDirForSort(b.data.sort),j=!!i.fieldView,k=j?h.db.query.bind(h.db,i.fieldView):h.db.allDocs,l=b.data.pageSize,m=b.data.page,n=function(){return j||d?a.utils.Promise.resolve(0):h.db.allDocs({startkey:"_design/",endkey:"_design￿"}).then(function(a){return a.rows.length})};h._validateFilter(b.data.filter,b.data.sort),g=this._getFilterQueryOptions(b.data.filter),d=!!g,void 0!==l?(void 0===m&&(m=1),f=l*(m-1)):f=void 0,e=void 0!==f||void 0!==l;var o=c.extend({include_docs:!1,reduce:"_count"},g),p=c.extend({include_docs:!0,descending:i.descending,skip:f,limit:l},g);n().then(function(a){return k.call(h.db,p).then(function(b){return j||d?e?k.call(h.db,o).then(function(a){return j?(b.total_rows=a.rows.length,b):(b.total_rows=a.rows.length,b)}):(b.total_rows=0,c.each(b.rows,function(){0!==this.doc._id.indexOf("_design/")&&(b.total_rows+=1)}),b):(b.total_rows-=a,b)})}).then(function(a){b.success(a)})["catch"](function(a){b.error([],a.status,a)})},_crudPromises:[],_crud:function(a,b,d,e){var f=this,g=new c.Deferred,h=g.promise(),i=function(){g.resolve();var a=f._crudPromises.indexOf(h);f._crudPromises.splice(a,1)};this._crudPromises.push(h),e.call(this,b).then(function(a){b._rev=a.rev,d.success(b),i()})["catch"](function(b){409===b.status&&console.log(kendo.format("kendo-pouchdb: conflict occured for {0}: {1}",a,b)),d.error([],b.status,b),i()})},create:function(a){var c=a.data;c._id=b.toIndexableString(c[this.idField]),this._crud("create",c,a,function(a){return this.db.put(a)})},update:function(a){var b=a.data;this._crud("update",b,a,function(a){return this.db.put(a)})},destroy:function(a){var b=a.data;this._crud("destroy",b,a,function(a){return this.db.remove(a)})},_getFieldViewAndDirForSort:function(a){var b,c,d;if(!a||0===a.length)return{descending:!1};if(a.length>1)throw new Error("Sorting by multiple fields is not supported by kendo-pouchdb");if(b=a[0].field,c=a[0].dir&&"desc"===a[0].dir,"_id"===b||b===this.idField)return{descending:c};if(d=this.fieldViews[b],!d)throw new Error("No PouchDB view provided for sorting by '"+b+"'");return{fieldView:d,descending:c}},_validateFilter:function(a,b){if(a&&0!==a.filters.length){var c=a.filters;if(c.length>1)throw new Error("array of filters is currently not supported");var d=c[0].field,e=b&&b.length>0?b[0].field:this.idField;if(e!=d)throw new Error("filtering by field and then sorting by another field is not supported")}},_getFilterQueryOptions:function(a){if(!a||0===a.filters.length)return void 0;var c=a.filters[0].field,d=a.filters[0].operator,e=c===this.idField||"_id"===c?b.toIndexableString(a.filters[0].value):a.filters[0].value;if(["neq","gt"].indexOf(d)>=0)throw new Error(kendo.format("{0} operator is currently not supported for field '{1}'",d,c));switch(d){case"eq":return{key:e};case"lt":return{endkey:e,inclusive_end:!1};case"lte":return{endkey:e,inclusive_end:!0};case"gte":return{startkey:e}}return void 0}}),e={type:"json",data:function(a){if(a.rows){var b=c.map(a.rows,function(a){return 0!==a.doc._id.indexOf("_design/")?a.doc:void 0});return b}return a},total:function(a){return a.total_rows}};c.extend(!0,kendo.data,{schemas:{pouchdb:e},transports:{pouchdb:d}});var f=kendo.data.DataSource.extend({init:function(a){if(a&&a.type&&"pouchdb"===a.type){var b;if(a=c.extend(!0,{},a),this._ispouchdb=!0,a.schema&&a.schema.model&&a.schema.model.fn&&a.schema.model.fn instanceof kendo.data.Model){if(b=a.schema.model,"_id"!==b.idField)throw new Error('The Model\'s id option should be "_id"')}else if(a=c.extend(!0,{schema:{model:{id:"_id"}}},a),"_id"!==a.schema.model.id)throw new Error('The model.id option should not be provided or should be "_id"');if(a.serverPaging=void 0===a.serverPaging?!0:a.serverPaging,a.serverFiltering=void 0===a.serverFiltering?!0:a.serverFiltering,a.serverSorting=void 0===a.serverSorting?!0:a.serverSorting,a.serverGrouping=void 0===a.serverGrouping?!0:a.serverGrouping,a.serverAggregates=void 0===a.serverAggregates?!0:a.serverAggregates,a.data)throw new Error("For DataSource of type pouchdb data option should not be provided");a.data={dataSource:this}}kendo.data.DataSource.fn.init.apply(this,arguments)},getByModelId:function(a){return this._ispouchdb?kendo.data.DataSource.fn.get.call(this,b.toIndexableString(a)):kendo.data.DataSource.fn.get.apply(this,arguments)}});f.create=kendo.data.DataSource.create,kendo.data.PouchableDataSource=f}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(a,b){b(window.PouchDB,window.pouchCollate)}); //# sourceMappingURL=kendo-pouchdb.min.js.map \ No newline at end of file diff --git a/dist/kendo-pouchdb.min.js.map b/dist/kendo-pouchdb.min.js.map index 440ef3f..e1793aa 100644 --- a/dist/kendo-pouchdb.min.js.map +++ b/dist/kendo-pouchdb.min.js.map @@ -1 +1 @@ -{"version":3,"file":"kendo-pouchdb.min.js","sources":["../kendo-pouchdb.js"],"names":["f","define","PouchDB","pouchCollate","Error","$","pouchdbTransport","kendo","data","RemoteTransport","extend","init","options","pouchdb","db","idField","fieldViews","this","dataSource","fn","call","push","callbacks","that","changes","since","live","include_docs","on","change","datasourceItem","currentCrudPromises","_crudPromises","slice","doc","when","apply","then","deleted","pushDestroy","get","_id","undefined","_rev","pushUpdate","pageSize","pushCreate","err","read","skip","fieldViewAndDir","_getFieldViewAndDirForSort","sort","queryMethod","fieldView","query","bind","allDocs","limit","page","countDesignDocs","utils","Promise","resolve","startkey","endkey","result","rows","length","_validateFilter","filter","filterQueryOptions","_getFilterQueryOptions","queryOptions","descending","totalDesignRows","response","total_rows","success","error","status","_crud","type","operation","deferred","Deferred","crudPromise","promise","resolveCrudDeferred","index","indexOf","splice","rev","console","log","format","create","toIndexableString","d","put","update","destroy","remove","field","dir","filters","filterField","sortField","filterOperator","operator","filterValue","value","key","inclusive_end","pouchdbSchema","docs","map","row","total","schemas","transports","PouchableDataSource","DataSource","Model","_ispouchdb","schema","model","id","serverPaging","serverFiltering","serverSorting","serverGrouping","serverAggregates","arguments","getByModelId","window","jQuery","amd","_"],"mappings":";;CAEA,SAAWA,EAAGC,GACVA,GAAQ,UAAW,gBAAiBD,IACrC,SAAUE,EAASC,GAElB,IAAKD,EACD,KAAM,IAAIE,OAAM,mDAGpB,KAAKD,EACD,KAAM,IAAIC,OAAM,2DAmYpB,OAhYA,UAAWC,GAGP,GAAIC,GAAmBC,MAAMC,KAAKC,gBAAgBC,QAC9CC,KAAM,SAAUC,GACZ,GAAIC,GAAUD,GAAWA,EAAQC,QAAUD,EAAQC,WAC/CC,EAAKD,EAAQC,GACbC,EAAUF,EAAQE,QAClBC,EAAaH,EAAQG,cAEzB,KAAKF,EACD,KAAM,IAAIV,OAAM,+BAGpB,MAAMU,YAAcZ,IAChB,KAAM,IAAIE,OAAM,4CAKpB,IAFAa,KAAKH,GAAKA,GAELC,EACD,KAAM,IAAIX,OAAM,oCAGpBa,MAAKF,QAAUA,EAEfE,KAAKD,WAAaA,EAElBC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MAAMC,GACrB,KAAM,IAAI3H,OAAM,gEAYxB,IANAQ,EAAQoH,aAAwCtF,SAAzB9B,EAAQoH,cAA6B,EAAOpH,EAAQoH,aAC3EpH,EAAQqH,gBAA8CvF,SAA5B9B,EAAQqH,iBAAgC,EAAOrH,EAAQqH,gBACjFrH,EAAQsH,cAA0CxF,SAA1B9B,EAAQsH,eAA8B,EAAOtH,EAAQsH,cAC7EtH,EAAQuH,eAA4CzF,SAA3B9B,EAAQuH,gBAA+B,EAAOvH,EAAQuH,eAC/EvH,EAAQwH,iBAAgD1F,SAA7B9B,EAAQwH,kBAAiC,EAAOxH,EAAQwH,iBAE/ExH,EAAQJ,KACR,KAAM,IAAIJ,OAAM,oEAIpBQ,GAAQJ,MAEJU,WAAYD,MAKpBV,MAAMC,KAAKkH,WAAWvG,GAAGR,KAAKyB,MAAMnB,KAAMoH,YAI9CC,aAAc,SAAUP,GACpB,MAAI9G,MAAK2G,WACErH,MAAMC,KAAKkH,WAAWvG,GAAGqB,IAAIpB,KAAKH,KAAMd,EAAa8F,kBAAkB8B,IAE3ExH,MAAMC,KAAKkH,WAAWvG,GAAGqB,IAAIJ,MAAMnB,KAAMoH,aAMxDZ,GAAoBzB,OAASzF,MAAMC,KAAKkH,WAAW1B,OAGnDzF,MAAMC,KAAKiH,oBAAsBA,GAElCc,OAAOhI,MAAMiI,QAETD,OAAOhI,OAEE,kBAAVN,SAAwBA,OAAOwI,IAAMxI,OAAS,SAAUyI,EAAG1I,GAAKA,EAAEuI,OAAOrI,QAASqI,OAAOpI"} \ No newline at end of file +{"version":3,"file":"kendo-pouchdb.min.js","sources":["../kendo-pouchdb.js"],"names":["f","define","PouchDB","pouchCollate","Error","$","pouchdbTransport","kendo","data","RemoteTransport","extend","init","options","pouchdb","db","idField","fieldViews","this","dataSource","fn","call","push","callbacks","that","changes","since","live","include_docs","on","change","datasourceItem","currentCrudPromises","_crudPromises","slice","doc","when","apply","then","deleted","pushDestroy","get","_id","undefined","_rev","pushUpdate","pageSize","pushCreate","err","read","applyFilter","applyPaging","skip","filterQueryOptions","fieldViewAndDir","_getFieldViewAndDirForSort","sort","useQuery","fieldView","queryMethod","query","bind","allDocs","limit","page","countDocsToSubtract","utils","Promise","resolve","startkey","endkey","result","rows","length","_validateFilter","filter","_getFilterQueryOptions","totalQueryOptions","reduce","queryOptions","descending","totalRowsToSubtract","response","totalResult","total_rows","each","indexOf","success","error","status","_crud","type","operation","deferred","Deferred","crudPromise","promise","resolveCrudDeferred","index","splice","rev","console","log","format","create","toIndexableString","d","put","update","destroy","remove","field","dir","filters","filterField","sortField","filterOperator","operator","filterValue","value","key","inclusive_end","pouchdbSchema","docs","map","row","total","schemas","transports","PouchableDataSource","DataSource","Model","_ispouchdb","schema","model","id","serverPaging","serverFiltering","serverSorting","serverGrouping","serverAggregates","arguments","getByModelId","window","jQuery","amd","_"],"mappings":";;CAEA,SAAWA,EAAGC,GACVA,GAAQ,UAAW,gBAAiBD,IACrC,SAAUE,EAASC,GAElB,IAAKD,EACD,KAAM,IAAIE,OAAM,mDAGpB,KAAKD,EACD,KAAM,IAAIC,OAAM,2DA+ZpB,OA5ZA,UAAWC,GAGP,GAAIC,GAAmBC,MAAMC,KAAKC,gBAAgBC,QAC9CC,KAAM,SAAUC,GACZ,GAAIC,GAAUD,GAAWA,EAAQC,QAAUD,EAAQC,WAC/CC,EAAKD,EAAQC,GACbC,EAAUF,EAAQE,QAClBC,EAAaH,EAAQG,cAEzB,KAAKF,EACD,KAAM,IAAIV,OAAM,+BAGpB,MAAMU,YAAcZ,IAChB,KAAM,IAAIE,OAAM,4CAKpB,IAFAa,KAAKH,GAAKA,GAELC,EACD,KAAM,IAAIX,OAAM,oCAGpBa,MAAKF,QAAUA,EAEfE,KAAKD,WAAaA,EAElBC,KAAKC,WAAaN,EAAQJ,KAAKU,WAE/BX,MAAMC,KAAKC,gBAAgBU,GAAGR,KAAKS,KAAKH,KAAML,IAGlDS,KAAM,SAAUC,GAEZ,GAAIC,GAAON,KACP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,OAAOvI,OAEE,kBAAVN,SAAwBA,OAAO+I,IAAM/I,OAAS,SAAUgJ,EAAGjJ,GAAKA,EAAE8I,OAAO5I,QAAS4I,OAAO3I"} \ No newline at end of file diff --git a/kendo-pouchdb.js b/kendo-pouchdb.js index 556021d..24dffc9 100644 --- a/kendo-pouchdb.js +++ b/kendo-pouchdb.js @@ -107,22 +107,27 @@ var that = this, fieldViewAndDir = this._getFieldViewAndDirForSort(options.data.sort), - queryMethod = fieldViewAndDir.fieldView ? that.db.query.bind(that.db, fieldViewAndDir.fieldView) : that.db.allDocs, + useQuery = !!fieldViewAndDir.fieldView, + applyFilter, + applyPaging, + queryMethod = useQuery ? that.db.query.bind(that.db, fieldViewAndDir.fieldView) : that.db.allDocs, skip, limit = options.data.pageSize, page = options.data.page, //returns total number of design docs in database - countDesignDocs = function () { - if (queryMethod !== that.db.allDocs) { //When allDocs is used, design documents are returned and needed to be substracted + countDocsToSubtract = function () { + if (useQuery || applyFilter) { //When allDocs is used, design documents are returned and needed to be subtracted return PouchDB.utils.Promise.resolve(0); } return that.db.allDocs({ startkey: "_design/", endkey: "_design\uffff" }).then(function (result) { return result.rows.length; }); - }; + }, + filterQueryOptions; that._validateFilter(options.data.filter, options.data.sort); - var filterQueryOptions = this._getFilterQueryOptions(options.data.filter); + filterQueryOptions = this._getFilterQueryOptions(options.data.filter); + applyFilter = !!filterQueryOptions; if (limit !== undefined) { if (page === undefined) { @@ -132,17 +137,40 @@ } else { skip = undefined; } + applyPaging = (skip!==undefined || limit!==undefined); - var queryOptions = $.extend({ include_docs: true, descending: fieldViewAndDir.descending, skip: skip, limit: limit }, filterQueryOptions); + var totalQueryOptions = $.extend({ include_docs: false, reduce: "_count" }, filterQueryOptions), + queryOptions = $.extend({ include_docs: true, descending: fieldViewAndDir.descending, skip: skip, limit: limit }, filterQueryOptions); - countDesignDocs().then(function (totalDesignRows) { + countDocsToSubtract().then(function (totalRowsToSubtract) { return queryMethod.call(that.db, queryOptions) .then(function (response) { - //TODO: If filter set, total_rows cannot be used - it counts all the documents, and not total filtered - response.total_rows -= totalDesignRows; //subtracts design documents from total_rows - options.success(response); + if (!useQuery && !applyFilter) { + response.total_rows -= totalRowsToSubtract; //subtracts design documents from total_rows + return response; + } else if (!applyPaging) { + response.total_rows = 0; + $.each(response.rows, function () { + if (this.doc._id.indexOf("_design/") !== 0) { + response.total_rows += 1; + } + }); + return response; + } else { + return queryMethod.call(that.db, totalQueryOptions) + .then(function (totalResult) { + if (!useQuery) { + response.total_rows = totalResult.rows.length; + return response; + } + response.total_rows = totalResult.rows.length; //strangely, even when reduce:"_count" used, rows are still returned. + return response; + }); + } }); - + }) + .then(function (response) { + options.success(response); }) .catch(function (err) { options.error([], err.status, err); diff --git a/package.json b/package.json index d1efcd9..7955e62 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "kendo-pouchdb", "title": "kendoPouchDB", - "version": "0.0.6", + "version": "0.0.7", "description": "Kendo UI adapter for PouchDB", "main": "kendo-pouchdb.js", diff --git a/tests/spec/kendo-pouchdbSpec.js b/tests/spec/kendo-pouchdbSpec.js index 4ae8b17..e84f0be 100644 --- a/tests/spec/kendo-pouchdbSpec.js +++ b/tests/spec/kendo-pouchdbSpec.js @@ -788,6 +788,26 @@ describe("kendo-pouchdb", function () { expect(datasource.at(2).passport).toBe(3); }); + describe("with paging", function () { + + beforeEach(function (done) { + datasource.pageSize(2); + datasource.page(2); + datasource.fetch().then(done); + }); + + it("total should be as without paging", function () { + expect(datasource.total()).toBe(3); + }); + + it("should return paged rows", function () { + var view = datasource.view(); + expect(view.length).toBe(1); + expect(view[0].passport).toBe(3); + }); + + }); + }); describe("sorting descending", function () { @@ -973,6 +993,26 @@ describe("kendo-pouchdb", function () { expect(datasource.total()).toBe(3); }); + describe("with paging", function () { + + beforeEach(function (done) { + datasource.pageSize(2); + datasource.page(2); + datasource.fetch().then(done); + }); + + it("total should be as without paging", function () { + expect(datasource.total()).toBe(3); + }); + + it("should return paged rows", function () { + var view = datasource.view(); + expect(view.length).toBe(1); + expect(view[0].passport).toBe(3); + }); + + }); + }); describe("filter with gte", function () {