简体   繁体   English

PouchDB没有使用cordova检测sqlite插件

[英]PouchDB not detecting sqlite plugin using cordova

I recently used PouchDB to get an easy way of developing through mobile phone but it seems there's a bit problem when I'm trying to deploy it on a mobile phone. 我最近使用PouchDB来通过手机轻松开发,但是当我尝试在手机上部署时,似乎有点问题。 You see, our data will contain a huge amount so the only option here is to use sqlite plugin for database instead of websql or indexeddb. 你看,我们的数据将包含大量数据,所以这里唯一的选择是使用sqlite插件来代替websql或indexeddb。 So I tried the example provided by the documentation and it worked pretty well. 所以我尝试了文档提供的示例,它运行得很好。 But when I console.log(pouch.adapter) it says "websql". 但是当我在console.log(pouch.adapter)中它说“websql”时。 I tried browsing for the database using eclipse but there was nothing there. 我尝试使用eclipse浏览数据库,但那里什么都没有。 How can I force pouchdb to use sqlite always? 我如何强制pouchdb始终使用sqlite? Thanks! 谢谢!

Tldr; Tldr; tried deploying pouchDB with sqlite plugin but instead it used websql. 尝试使用sqlite插件部署pouchDB,但它使用了websql。 trying to force pouchDB to use sqlite all the time. 试图强迫pouchDB一直使用sqlite。

I responded in the Google Groups, but basically db.adapter will report "websql" whether it's using WebSQL or the SQLite plugin. 我在谷歌小组回复,但基本上db.adapter将报告“websql”是否使用WebSQL或SQLite插件。 Kinda confusing, sorry about that! 有点困惑,抱歉!

Update : as of PouchDB 3.4.0, you can call db.info().then(console.log.bind(console)) and print out the database info, and it will report sqlite_plugin true or false. 更新 :从PouchDB 3.4.0开始,您可以调用db.info().then(console.log.bind(console))并打印出数据库信息,它将报告sqlite_plugin true或false。 Makes debugging easier. 使调试更容易。 :) :)

One of the latest versions have had a bug and pouchdb was not using sqllite. 其中一个最新版本有一个错误,pouchdb没有使用sqllite。 You can see more here: https://github.com/pouchdb/pouchdb/issues/3505 你可以在这里看到更多: https//github.com/pouchdb/pouchdb/issues/3505

Make sure you install this plugin 确保安装此插件

cordova plugin add https://github.com/litehelpers/Cordova-sqlite-storage

and the use this in your JS script 并在您的JS脚本中使用它

var db = new PouchDB('new_puchDB', {adapter : 'websql'});

ensure that the plugin was installed correctly and your cordova versions is 3.0+ (works with latest -- I'm using it as we speak) 确保插件安装正确,并且您的cordova版本是3.0+(与最新一起使用 - 我正在使用它,因为我们说话)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM