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

db.rel.find in Chrome Console fails with error #98

Open
jetamartin opened this issue May 31, 2018 · 4 comments
Open

db.rel.find in Chrome Console fails with error #98

jetamartin opened this issue May 31, 2018 · 4 comments

Comments

@jetamartin
Copy link

jetamartin commented May 31, 2018

This may not be the right forum for posting this question/issue...but after searching the relational-pouch GitHub website and reading all documentation, reviewing Issues, searching on stackOverflow and viewing multiple videos on pouchDB & document databases for possible answers/general information I'm not quite sure where to go at this point. I'm stuck. Hoping someone can steer me in the right direction.

I'm more than happy to share all the details of my code and config but before I did that I wanted to share the highlights of what I've done and the problem that I'm experiencing to see if anyone can help me in this forum.

Problem Summary:
I'm trying to use relational-pouch "plugin" for my webApp. I'd like to use the relational-pouch methods defined in the API from the Chrome Console so that I can become familiar with how to store and access data in the DB. This is critical for me.

The problem is none of the relational-pouch APIs that I've tested work from the console. I can successfully use these relational-pouch API's in my app (at least i've tested "db.rel.save()") but when I try and use the same exact command (copied from my code) in the console (but with a different id and user data) it fails with the following message "Uncaught TypeError: Cannot read property 'find' of undefined". BUT when I use other pouchDB commands in the console like "db.allDocs()" or db.info() they seem to work perfectly.

So why are the relational-pouch API's working fine in my app but not in the console?

Background:

  1. I successfully included/installed pouchdb.js, pouchdb.find.js and pouchdb.relational-pouch.js in that order;

  2. Added script tags in that order into my index.html file without error.

  • <script src="https://cdnjs.cloudflare.com/ajax/libs/pouchdb/6.4.3/pouchdb.min.js"></script>
  • <script src="js/pouchdb.find.js"></script>
  • <script src="js/pouchdb.relational-pouch.js"></script>
  1. Successfully created a pouchDB via "var db = new PouchDB('taskIt');"

  2. Used db.setSchema() to define my "schema" and used db.rel.save() method in my webapp to successfully load seed data into DB (verified through Chrome Dev tools ...was able to successfully see all all records I added. Note: My schema defines 4 "types" of data: user, taskList, taskItem and taskItemNotifications;

  3. I was able to use "db.allDocs({include_docs: true})" from the Chrome Console to successfully retrieve all the records in the database.

  4. However, when I try using the relational-pouchDB methods in Chrome console (e.g., db.rel.find(), db.rel.save()) I receive the following error message: "VM3152:1 Uncaught TypeError: Cannot read property 'find' of undefined ". (This message is for db.rel.find()...but I receive the same type of message with 'db.rel.save() method).

This would imply that db.rel is undefined? I'm puzzled because the "db.allDocs({include_docs: true})" command works just fine....so clearly db is defined. Maybe the .rel part of db.rel.find() method is undefined? Why?

BTW, when I downloaded relational-pouch (via the download button). I only added "pouchdb.relational-pouch.js" to my project. I didn't include any of the other items that came with the download (e.g., anything in the lib directory e.g., "pouch-utils.js" ) as the <script> tag specified in the installation directions only referenced the "pouchdb.relational-pouch.js" file.

Any thoughts on what might be wrong? Is there something else I need to do to use the relational-pouch commands from the Chrome Console?

Again I'd be happy to share additional details as needed....I just didn't want to include superfluous info at this point...especially if not necessary.

Also, if this is not the appropriate forum for asking questions can someone point me to where I can get answers to general questions that I might have re: the usage of the relational APIs? I feel like a video on how to use the relation API's to build an application is sorely needed. PouchDb has a basic video but there doesn't appear to be any similar video for relational-pouchdb. I think this is really needed to get widespread usage of this plugin.

Regards,
Jet

@jetamartin jetamartin changed the title db.rel.find fails with error db.rel.find in Chrome Console fails with error May 31, 2018
@fernandacipriano
Copy link

Eu preciso dessa mesma resposta... você conseguiu alguma coisa?
Está acontecendo a mesma coisa comigo =/

@gerciljunio
Copy link

@fernandacipriano também estou com este problema, mas levando em consideração que a pergunta deste rapaz, foi postada em 2018, acho que não teremos resposta! rs!

@fernandacipriano
Copy link

Uma pessoa me ajudou a achar o problema...
Estou fazendo com quasar e tive que na configuração (quasar.conf.js) adicionar no obj "build", dentro de extendWebpack (cfg) {, a seguinte linha:

cfg.resolve.alias['pouchdb-promise'] = path.join(__dirname, '/node_modules/pouchdb-promise/lib/index.js'),

Essa pessoa me explicou que é porque o relational ainda usa a promise do pouchdb, por isso ele se perde se não fizer essa configuração do alias na aplicação.

Espero que posso ajudar mais alguém!

Obrigada!

@fernandacipriano
Copy link

Screenshot_1

Segue a imagem do quasar.conf.js

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

3 participants