hoodiehq / hoodie-store-server-api

API to manage databases, access and replications, backed by PouchDB
Apache License 2.0
4 stars 5 forks source link

Store.open doesn't find the store #24

Open kevinmerckx opened 6 years ago

kevinmerckx commented 6 years ago

Hi Hoodie team,

I've manually set up Hoodie with a Node script.

const Hapi = require('hapi');
const hoodie = require('hoodie').register;
const PouchDB = require('pouchdb-core')
  .plugin(require('pouchdb-find'))
  .plugin(require('pouchdb-replication'))
  .plugin(require('pouchdb-mapreduce'))
  .plugin(require('pouchdb-adapter-fs'))
  .defaults({
    prefix: '.hoodie/data/'
  });
const Store = require('@hoodie/store-server-api')(PouchDB)

const server = new Hapi.Server()
server.connection({
  host: 'localhost',
  port: 8080
});

server.register({
  register: hoodie,
  options: { // pass options here
    inMemory: false,
    public: 'dist',
    PouchDB: PouchDB
  }
}, function (error) {
  if (error) {
    throw error
  }

  server.start(function (error) {
    if (error) {
      throw error
    }

    console.log('Server running at:', server.info.uri);
    // HERE I want to do some task with the users' stores
    Store.open('userXXXYYYZZ'); // DOES NOT WORK

  })
});

Everything's fine client side. I'd like to work on the databases to replicate data and do some server side tasks. I tried to open a user's store given its id but it always fails with Missing: Store does not exist. I use the fs adapter and I do see the files! Is there something I'm missing?

gr2m commented 6 years ago

Could you create a test repository which would allow us to replicate the problem? That would be very helpful

What is userXXXYYYZZ in your example above?