pouchdb-server icon indicating copy to clipboard operation
pouchdb-server copied to clipboard

Can’t use with pouchdb-adapter-node-websql?

Open fasiha opened this issue 8 years ago • 2 comments

I hope I’m not doing something totally stupid, but I have a command-line Node app that uses pouchdb-adapter-node-websql with the SQLite backend—and that part works great.

But when I attach express-pouchdb to that PouchDB instance and try to query over REST, express-pouchdb tries to find a LOCK file “inside” the SQLite file and breaks.

Example:

var PouchDB = require('pouchdb');
PouchDB.plugin(require('pouchdb-adapter-node-websql'));
var db = new PouchDB('mypouchdb.db', { adapter: 'websql' });

var express = require('express');
var app = express();
app.use('/db', require('express-pouchdb')(PouchDB, { mode: 'fullCouchDB' }));
app.listen(3001, () => console.log('Running!'));

Now, when I try to hit a _all_docs endpoint:

$ curl http://127.0.0.1:3001/db/mypouchdb.db/_all_docs
{"error":"OpenError","reason":"IO error: mypouchdb.db/LOCK: Not a directory"}

If I change the backend to be a leveldb (the default), i.e.,

var PouchDB = require('pouchdb');
var db = new PouchDB('mypouchlevel'); // LevelDB, *not* SQLite

// same Express setup as above

then curl http://127.0.0.1:3001/db/mypouchlevel/_all_docs prints out my documents—since mypouchlevel is a directory with level stuff inside, while mypouchdb.db is a SQLite db file.

fasiha avatar Jul 21 '17 17:07 fasiha

I was able to reproduce the problem. The error looks to me like an issue with pouchdb-adapter-node-websql. I remember problems when setting a path for the db files, where you’d need to create the path manually because the adapters woudn’t do it.

I’m not familiar with the pouchdb-adapter-node-websql adapter myself though and can’t help with it, I’m afraid. Hopefully someone else can. Please let us know if you find the cause of the problem yourself :)

gr2m avatar Jul 21 '17 18:07 gr2m

I have the same problem now. 5 years later 🤷

fredguth avatar Jul 06 '22 17:07 fredguth