ujjwalguptaofficial / JsStore

A complete IndexedDB wrapper with SQL like syntax.
http://jsstore.net/
MIT License
851 stars 109 forks source link

Select boolean column #105

Closed bdhaegar closed 5 years ago

bdhaegar commented 5 years ago

I am struggling to select data by querying a boolean field. I defined a column as described below:

{ name: "DeleteMe", dataType: 'boolean', enableSearch: true }

Then I am trying to select all records with the boolean value "true" in the column "DeleteMe":

connection2.select({ from: "NCRTable",

where: {
    DeleteMe: true
}

}).then(function(results) {
   //results will be array of objects.
   console.log(results);

}).catch(function(error) { alert(error.message); });

Any advise on how to accomplish this would be highly appreciated. Thank you in advance. This is the error message I get:

  JsStoreWorker../src/worker/business/base.ts.Base.onExceptionOccured @ jsstore.worker.js:163
  JsStoreWorker../src/worker/business/select/instance.ts.Instance.execute @ jsstore.worker.js:3229
  JsStoreWorker../src/worker/queryexecutor.ts.QueryExecutor.select @ jsstore.worker.js:6789
  JsStoreWorker../src/worker/queryexecutor.ts.QueryExecutor.executeLogic @ jsstore.worker.js:6602
  JsStoreWorker../src/worker/query_executor.ts.QueryExecutor.checkConnectionAndExecuteLogic @ jsstore.worker.js:6553
  JsStore../src/main/instancehelper.ts.InstanceHelper.sendRequestToWorker @ jsstore.js:700
  JsStore../src/main/instancehelper.ts.InstanceHelper.executeQry @ jsstore.js:679
  JsStore../src/main/instancehelper.ts.InstanceHelper.processFinishedQuery @ jsstore.js:655
  JsStoreWorker../src/worker/queryexecutor.ts.QueryExecutor.returnResult @ jsstore.worker.js:6583
  onSuccess @ jsstore.worker.js:6589
  dbRequest_1.onsuccess @ jsstore.worker.js:1711
  IndexedDB (async)    
  JsStoreWorker../src/worker/business/open_db.ts.OpenDb.execute @ jsstore.worker.js:1698
  (anonymous) @ jsstore.worker.js:6718
  Promise.then (async)    
  (anonymous) @ jsstore.worker.js:6715
  Promise.then (async)    
  JsStoreWorker../src/worker/queryexecutor.ts.QueryExecutor.openDb @ jsstore.worker.js:6712
  JsStoreWorker../src/worker/queryexecutor.ts.QueryExecutor.executeLogic @ jsstore.worker.js:6633
  JsStoreWorker../src/worker/query_executor.ts.QueryExecutor.checkConnectionAndExecuteLogic @ jsstore.worker.js:6547
  JsStore../src/main/instancehelper.ts.InstanceHelper.sendRequestToWorker @ jsstore.js:700
  JsStore../src/main/instancehelper.ts.InstanceHelper.executeQry @ jsstore.js:686
  JsStore../src/main/instancehelper.ts.InstanceHelper.prcoessExecutionOfQry @ jsstore.js:673
  (anonymous) @ jsstore.js:667
  JsStore../src/main/instance_helper.ts.InstanceHelper.pushApi @ jsstore.js:660
  JsStore../src/main/instance.ts.Instance.openDb @ jsstore.js:323
  (anonymous) @ VM392591:669
  Promise.then (async)    
  Page_NCRs_Search_onLoad @ VM392591:667
  Page_NCRs_Search_js @ VM392591:978
  (anonymous) @ VM392591:982
  dispatch @ jquery-2.1.1.js:4409
  elemData.handle @ jquery-2.1.1.js:4095
  trigger @ jquery-2.1.1.js:4324
  (anonymous) @ jquery-2.1.1.js:4875
  each @ jquery-2.1.1.js:375
  each @ jquery-2.1.1.js:139
  trigger @ jquery-2.1.1.js:4874
  _trigger @ jquery.mobile-1.4.5.js:1219
  _createWidget @ jquery.mobile-1.4.5.js:1001
  _createWidget @ jquery.mobile-1.4.5.js:4436
  (anonymous) @ jquery.mobile-1.4.5.js:835
  $.. @ jquery.mobile-1.4.5.js:796
  (anonymous) @ jquery.mobile-1.4.5.js:947
  each @ jquery-2.1.1.js:375
  each @ jquery-2.1.1.js:139
  $.fn. @ jquery.mobile-1.4.5.js:942
  _enhance @ jquery.mobile-1.4.5.js:4876
  (anonymous) @ jquery.mobile-1.4.5.js:835
  _include @ jquery.mobile-1.4.5.js:4884
  (anonymous) @ jquery.mobile-1.4.5.js:835
  (anonymous) @ jquery.mobile-1.4.5.js:5095
  proxy @ jquery-2.1.1.js:513
  fire @ jquery-2.1.1.js:3073
  fireWith @ jquery-2.1.1.js:3185
  done @ jquery-2.1.1.js:8251
  (anonymous) @ jquery-2.1.1.js:8598
  load (async)    
  send @ jquery-2.1.1.js:8615
  ajax @ jquery-2.1.1.js:8152
  load @ jquery.mobile-1.4.5.js:5240
  (anonymous) @ jquery.mobile-1.4.5.js:835
  _loadUrl @ jquery.mobile-1.4.5.js:5375
  (anonymous) @ jquery.mobile-1.4.5.js:835
  change @ jquery.mobile-1.4.5.js:5465
  (anonymous) @ jquery.mobile-1.4.5.js:835
  (anonymous) @ jquery.mobile-1.4.5.js:933
  each @ jquery-2.1.1.js:375
  each @ jquery-2.1.1.js:139
  $.fn. @ jquery.mobile-1.4.5.js:919
  Apperyio.navigateTo @ appery.js:2055
  click @ VM392590:288
  dispatch @ jquery-2.1.1.js:4409
  elemData.handle
bdhaegar commented 5 years ago

I found this:

https://w3c.github.io/IndexedDB/#key-construct

So I think a boolean value is not a valid key in indexeddb. If there is no way around it other to store the true or false value in a string column in order to query them it would be helpful to mention in the help manual of jsstore.net

ujjwalguptaofficial commented 5 years ago

any suggestion about where i should add it ?

ujjwalguptaofficial commented 5 years ago

note added in column doc -http://jsstore.net/tutorial/column/.