Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create subscribe query #52

Open
nickasd opened this issue Apr 12, 2017 · 5 comments
Open

Unable to create subscribe query #52

nickasd opened this issue Apr 12, 2017 · 5 comments

Comments

@nickasd
Copy link

nickasd commented Apr 12, 2017

Until now I used the default database adapter for ShareDB, but since I want to support persistent storage, I decided to use this adapter. Only there seems to be a problem when calling connection.createSubscribeQuery(...):

TypeError: Cannot read property '$query' of undefined
    at DB.ShareDbMongo.checkQuery (node_modules\sharedb-mongo\index.js:853:12)
    at DB.ShareDbMongo._getSafeParsedQuery (node_modules\sharedb-mongo\index.js:939:18)
    at DB.ShareDbMongo._query (node_modules\sharedb-mongo\index.js:625:21)
    at node_modules\sharedb-mongo\index.js:686:10
    at node_modules\sharedb-mongo\index.js:74:12
    at DB.ShareDbMongo.getDbs (node_modules\sharedb-mongo\index.js:109:26)
    at DB.ShareDbMongo.getCollection (node_modules\sharedb-mongo\index.js:71:8)
    at DB.ShareDbMongo.query (node_modules\sharedb-mongo\index.js:683:8)
    at Backend._query (node_modules\sharedb\lib\backend.js:495:14)
    at node_modules\sharedb\lib\backend.js:452:15

This is the code which creates the ShareDB backend:

var ShareDB = require('sharedb');
var ShareDBMongo = require('sharedb-mongo');
var sharedb = new ShareDB({db: ShareDBMongo('mongodb://localhost:27017')});
var connection = sharedb.connect();

Everything used to run correctly before (without providing the option, i.e. just using new ShareDB()).

@curran
Copy link
Contributor

curran commented Jul 13, 2017

Could you please post your code that invokes connection.createSubscribeQuery(...) and describe what the arguments are? I suspect it's the stuff that's been replaced by ... in your description that's causing the issue.

@nickasd
Copy link
Author

nickasd commented Jul 13, 2017

It's really just those lines, and the argument is just the collection name: connection.createSubscribeQuery('files'). Is it possible that the MondoDB installation is not detected correctly? Would there be a different exception if this were the case?

@curran
Copy link
Contributor

curran commented Jul 13, 2017

Try connection.createSubscribeQuery('files', {})

@nickasd
Copy link
Author

nickasd commented Jul 31, 2017

Wow, that actually worked. Thanks!
Perhaps it should be documented somewhere, since that second parameter is not necessary for the default mingo-memory adapter.

@curran
Copy link
Contributor

curran commented Aug 1, 2017

Nice!

It would be good indeed if this difference between Mingo and Mongo adapters were documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants