pubkey / rxdb

A fast, local first, reactive Database for JavaScript Applications https://rxdb.info/
https://rxdb.info/
Apache License 2.0
21k stars 1.02k forks source link

find not working #60

Closed S4RD7R closed 7 years ago

S4RD7R commented 7 years ago

Can't get rxdb to find data in a collection. I have tried numerous variations of the find.

CACHEDB.collections.documents.find() .where('cache.name').eq(pathData.base) .where('cache.path').eq(pathData.dir) .exec() .then( (document) => { resolve(document); });

I have created an index on the database collection

  col.pouch.createIndex({
    index: {
      fields: ['cache.name', 'cache.path'],
      name: 'cachenamepath',
      ddoc: 'cachenamepath',
      type: 'json'
    }

I know there is data that matches the query.

S4RD7R commented 7 years ago

I think there is an issue in KeyCompressor.js Function compressQuery

In here I think it should be making a call to schema.doKeyCompression

My schema specifies "disableKeyCompression": true

I then setup an index directly on the pouch instance in the collection. (Another issue)

So the data does not contain compressed keys and the query shouldn't either. Making the change I do get results from Find()

So my next question since I can directly create an index on the Pouch instance in the collection with a.b and this works why can't I specify this in the schema. I get "index can only be defined at top-level" why is this when clearly they do work in PouchDB?

pubkey commented 7 years ago

@MMJM The problem was indeed with the keycompressor. It's solved now, please check out RxDB v3.

S4RD7R commented 7 years ago

Super. Thanks for the work