calvinmetcalf / crypto-pouch

plugin for encrypted pouchdb/couchdb databases
MIT License
243 stars 44 forks source link

How import CryptoPouch with Typescript ? #73

Closed jusmar3105 closed 2 years ago

jusmar3105 commented 4 years ago

import PouchDB from 'pouchdb'; import PouchdbFind from 'pouchdb-find'; import CryptoPouch from 'crypto-pouch'; PouchDB.plugin(PouchdbFind); PouchDB.plugin(CryptoPouch); let db: any = new PouchDB('datalayer'); db.crypto('password').then((res: any) => { console.log(res); });

this doesn't work for me :/

in the browser I have the following error Uncaught TypeError: Cannot read property 'then' of undefined

garbados commented 3 years ago

Howdy! That code should work with crypto-pouch 4.0.0. Previously, db.crypto() was not asynchronous, which is why it didn't have a .then() method -- it wasn't a promise!

Let me know if you're still having issues :)

ramblin-rose commented 2 years ago

@Jusmaar there's a type definition now.

$ npm install --save-dev @types/crypto-pouch